I am getting the error
Could not load type MvcApplication
when I try to run my website.
How to correct it?
I know there are lots of solutions to this already, but I thought I'll just mention what solved it for me.
My configuration was set to Debug. Changing it to Release did the trick for me.
I was getting this error because I was running the project despite some compile time errors. This I didn't notice.
In some circumstances, new projects you create are not by default set to build. If you right-click on your solution, choose Properties
, and choose the Configuration Properties
| Configuration
node on the left and ensure your project has a checkmark under the Build
column. In normal circumstances I've found this happens by default. In other circumstances (I happen to have a somewhat complex Web Api / Xamarin Android and iOS / Mvc 5 solution that exhibits this behavior) the checkmark isn't present.
This is related to the other answers -- if your web projet's assembly is unavailable, you get this error. But this might be a common scenario, especially since you do in fact compile your solution -- the project just doesn't get built.
This can also happen while running the project in visual studio if your IIS Express has/is hosting an old/different project using the same port assignment.
To fix this, you can change the port assignment for this project or close IIS Express.
What worked for me was restarting Visual Studio.
I tried manually rebuilding, performing a clean and rebuild, and deleting the bin folder all of which did not work. My output path was already set to bin\
If you changed a namespace make sure to right click and refactor.