Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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. 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.

This is the error:

Could not load type 'MvcApplication1.Views.Home.Index'.

Any ideas what the problem could be?

like image 659
Goober Avatar asked May 08 '09 19:05

Goober


3 Answers

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

Basically, add the Views directory's web.config to your target Views directory. 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. 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.

like image 133
Jon Davis Avatar answered Nov 06 '22 21:11

Jon Davis


Are you running the current version of MVC? There was a big update in the Release Candidate that removed the code-behinds on views.

I ran into the same issue. Uninstalling MVC, then reinstalling fixed the problem for me. This can be done in Control Panel --> Add/Remove Programs.

Hope this helps, Adam

like image 37
Adam Avatar answered Nov 06 '22 22:11

Adam


I had a similar "Could Not Load Type" problem with ASP.NET MVC in my Global.asax. 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!

like image 1
Kalid Avatar answered Nov 06 '22 22:11

Kalid