Could not load file or assembly 'System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'

2.9k Views Asked by At

error ASPRUNTIME : The pre-application start initialization method Initialize on type Elmah.Mvc.Bootstrap threw an exception with the following error message: Could not load file or assembly 'System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference.

After updating the NuGet package "Microsoft.AspNet.Mvc" from 5.2.3 to 5.2.7 , I am getting the above error during publish (My local as well as on the build server)

Upon searching I was able to find this online: https://developercommunity.visualstudio.com/content/problem/228901/the-pre-application-start-initialization-method-in.html

Can someone help me out.

1

There are 1 best solutions below

3
Skye MacMaster On

The web.config file probably didn't get updated. The DLL version for 5.2.7 is 5.2.7.0. The error message mentions 4.0.0.0. So look for 4.0.0.0 in your web.config and change it to 5.2.7.0.

There will likely be several places in the web.config file to update.

Also, be sure to check the web.config in the Views folder not just the one in the project folder.