I am getting the error
Could not load type MvcApplication
when I try to run my website.
How to correct it?
If you're hosting in IIS express and you open your project in two different locations, then you might see this error.
The solution is to go to Project/Properties/Web/Servers
and click Create Virtual Directory
.
I already had bin/
in my build tab. I got global.asax from another copy of the project, but that didn't work out.
The solution that finally worked for me was to remove the bin/
folder and create a new empty folder with the same name.
Make sure you shouldn't have to open the MVC project like File->Open Web Site use File->Open Project instead.
-For me, the fix was to change the output path in the build tab.
I changed the output path to bin\
and the error went away.
-Another fix could be that you have the wrong start up project set.
I was getting the same error and inspite of doing everything mentioned here and elsewhere nothing worked. Turned out that I had copied the source code of global.asax.cs from a previous version of the project which had a different name. So the namespace Test
should have been namespace Test.WebUI
. A silly mistake of course and am a bit embarrassed to write this! But writing in the hope that a similar error from anyone else may lead him to check this trivial aspect as well.
The solution for me was to right click on the Mvc project, choose properties and click Create Virtual Directory.
A message box popped up saying that the project was mapped to the wrong folder (it showed the folder for a different TFS project. It gave the option to map it back to the correct folder.