Sunday, 8 September 2013

ASP.MVC failed after deployment - works fine on my local!

I have been working on a site for a while that has been working fine on our local dev machines as well as our CI (DevTest). However, when I have deployed it to production it exploded with 

Server Error in '/' Application.
Could not load file or assembly 'System.Web.Mvc' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

Solution

This will make sure all DLLs that are required at run-time are included with the assets, therefore you will NOT need to install MVC3/4 on production server.
  1. Open your Solution (*.sln file)
  2. In each of the projects that use "MVC" open "Reference" 
  3. Right click System.Web.Mvc and select Properties
  4. Change "Copy Local" to True
  5. Save solution and rebuild.
  6. Check Bin folder for System.Web.Mvc.dll
Note: Dependable on what other parts of MVC you use you might also need following DLLs 
  • Microsoft.Web.Infrastrucutre.dll
  • System.Web.Helpers.dll
  • System.Web.Razor.dll
  • System.Web.Webpages.dll
  • System.Web.WebPages.Deployment.dll
  • System.Web.WebPages.Razor.dll

No comments :

Post a comment