Could not load file or assembly 'System.Web.WebPages.Razor, Version=2.0.0.0
This problem started when I did 'Remove Unused References'. The website still worked on my local machine, but did not worked on the server after publishing.
I fixed this problem by doing the following,
- Open 'Package Manager Console' in Visual Studio
- Uninstall-Package Microsoft.AspNet.Mvc
- Install-Package Microsoft.AspNet.Mvc
After much pain, googling and hair pulling, I ended up uninstalling MVC 4 using nuget, deleting all references to MVC, razor and infrastructure from the web config, deleting the dlls from the bin folder - then using nuget to reinstall everything. It took less time then trying to figure out why the dlls did not match.
how do I find out what is referencing System.Web.WebPages.Razor v2.0.0.0?
Just read your exception stacktrace:
Calling assembly : Microsoft.Web.Helpers, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
So it seems that you are using the Microsoft.Web.Helpers
which in turn depends on System.Web.WebPages.Razor, Version=2.0.0.0
.
So simple. In Nuget Package Manager Console:
Update-Package Microsoft.AspNet.Mvc -Reinstall