简体   繁体   English

执行时ASP.Net MVC“无法加载类型”

[英]ASP.Net MVC “Could Not Load Type” when executing

I have a very simple ASP.Net MVC Application that I have produced from an online tutorial. 我有一个非常简单的ASP.Net MVC应用程序,我是通过在线教程生成的。 I've followed it exactly, step by step and have tried multiple times but keep getting the same error when I execute the code. 我已经完全按照它一步一步地尝试了多次,但在执行代码时仍然遇到同样的错误。

The program just displays an index page which lists a series of data from an sql server database using linq to sql. 该程序只显示一个索引页面,该页面列出了使用linq到sql的sql server数据库中的一系列数据。

This is the error: 这是错误:

Could not load type 'MvcApplication1.Views.Home.Index'. 无法加载类型'MvcApplication1.Views.Home.Index'。

Any ideas what the problem could be? 任何想法可能是什么问题?

Possible answer here: 可能的答案:

http://www.jondavis.net/techblog/post/2009/04/29/Set-Up-IIS-For-An-MVC-App-When-All-Else-Fails-Check-View-Config.aspx http://www.jondavis.net/techblog/post/2009/04/29/Set-Up-IIS-For-An-MVC-App-When-All-Else-Fails-Check-View-Config.aspx

Basically, add the Views directory's web.config to your target Views directory. 基本上,将Views目录的web.config添加到目标Views目录。 Although, it doesn't sound like you're using a strongly typed view, or aren't deploying your code. 虽然,听起来好像您使用的是强类型视图,或者没有部署代码。

Also, I have seen this problem also appear if the compile settings are removed from web.config. 此外,我已经看到如果从web.config中删除编译设置也会出现此问题。 In an ASP.NET MVC project created in Visual Studio 2008, those settings are included in web.config, and they should remain or else this error will occur. 在Visual Studio 2008中创建的ASP.NET MVC项目中,这些设置包含在web.config中,它们应保留,否则将发生此错误。

I had a similar "Could Not Load Type" problem with ASP.NET MVC in my Global.asax. 我的Global.asax中的ASP.NET MVC有类似的“无法加载类型”问题。 The fix was to ensure the case of the inherits property was the same as the class it was referencing -- I didn't realize it was case sensitive! 修复是为了确保inherits属性的情况与它引用的类相同 - 我没有意识到它区分大小写!

Are you running the current version of MVC? 你在运行当前版本的MVC吗? There was a big update in the Release Candidate that removed the code-behinds on views. Release Candidate中有一个重大更新,删除了视图的代码隐藏。

I ran into the same issue. 我遇到了同样的问题。 Uninstalling MVC, then reinstalling fixed the problem for me. 卸载MVC,然后重新安装修复了我的问题。 This can be done in Control Panel --> Add/Remove Programs. 这可以在控制面板 - >添加/删除程序中完成。

Hope this helps, Adam 亚当,希望这会有所帮助

That seems like a pretty ambiguous error to me. 这对我来说似乎是一个非常模糊的错误。 What hints does your Stack Trace give you? Stack Trace为您提供了哪些提示? What framework method throws the exception? 什么框架方法抛出异常?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM