I am getting the error
Could not load type MvcApplication
when I try to run my website.
How to correct it?
As dumb as it might sound, tried everything and it did not work and finally restarted VS2012 to see it working again.
My solution: Because I created the problem! I had changed the namespace in Global.asax.cs
You also need to change the Inherits attribute value in the Global.asax.
[Extracted from question]
If you are getting this error: "Could not load type MvcApplication", look at the Output path of your project and make sure it is set to 'bin\'. The problem is that the AspNetCompiler cannot find the files if they are not in the default location.
Another side effect of changing the output folder is that you will not be able to debug your code and it comes up with a message saying that the Assembly info cannot be found.
I had this frustrating error in development environment in Visual studio, and turned out the reason was quite dumb. In short if you have more than one web projects/sites in solution: make sure that the port you are trying to access the website is the same as configured in the Project Properties->Web
In my case, the error was caused because I was using a different port to access the website (in the browser) while the project in solution was assigned another port. To explain a little bit more, I had two website projects in my solution Website1(assigned port 8001 in ISS by Visual-Studio) and Website2(assigned port 8101 in ISS by Visual-Studio). So even though I was building Website1, I was trying to access the website using locahost:8101.
Now that I finally realized the problem, I see that @StingyJack's comment addresses the similar issue as well.
Just do a manual build on your solution.
If you are using local IIS try deleting the website registration in IIS manager and then recreating it manually.
I had the same issue and solved it with below steps