Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Could not load file or assembly 'System.Web.Mvc, Version=3.0.0.0

I've had a look at similar postings but haven't found one that has helped fix this issue.

Just briefly, I have an mvc3 project running on azure. A couple of days ago it lost it's reference to System.Web.MVC for some reason. So I added the reference and changed the Copy Local property to True. It built and ran on the local emulator ok. I then published it and got the following message when visting the website.

"Could not load file or assembly 'System.Web.Mvc, Version=3.0.0.0"

It turns out I only version 3.0.0.1 and not 3.0.0.0 which is stated in my web.congig file. I've tried changing the value in web.config in both the assembly and runtime sections to 3.0.0.1 but this throws another exception in azure.(although didn't change the Public Token)

I've also tried Add Deployable Dependency but this has made no difference and I've tried downloading and adding vers 3.0.0.0 to the project but vs didn't like this dll when publishing.

I've also tried changing the property Specifc Version for the assembly to False but this hasn't worked.

So for some reason I don't have v3.0.0.0 anymore but don't know how to change my project to use v3.0.0.1 I guess.

Server Error in '/' Application.

Configuration Error Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately.

Parser Error Message: Could not load file or assembly 'System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

Source Error: Line 39: Line 40: Line 41: Line 42: Line 43:

Source File: E:\sitesroot\0\web.config Line: 41

Assembly Load Trace: The following information can be helpful to determine why the assembly 'System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' could not be loaded. WRN: Assembly binding logging is turned OFF. To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1. Note: There is some performance penalty associated with assembly bind failure logging. To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog].

like image 571
Mat Amos Avatar asked Oct 18 '14 13:10

Mat Amos


3 Answers

Thank's guy's. I actually just commented out the assembly line of code for the mvc assemble and changed the runtime binding code to look for v 3.0.0.1 in web.config and this has done the trick. I'm not sure if that was the best solution but having spent over a day on it time was a big factor.

like image 192
Mat Amos Avatar answered Nov 03 '22 19:11

Mat Amos


  • I was getting a very similar error
  • My solution had previously been working and nothing had changed apart from some activities using source control
  • I created a completely new workspace and checked out the entire source code again to the new workspace, and this fixed the issue (just doing a 'get' and a 'Get Specific Version' wasn't enough)
    • Looks like something had got screwed up in my workspace that prevented the compiler from finding the correct .dll. Possibly related to finding it in the GAC?
like image 33
Chris Halcrow Avatar answered Nov 03 '22 20:11

Chris Halcrow


I have had this problem on and off randomly for a while and I now know why. When you update a nuget package and the package has a web.config file as part of the nuget package, it merges the content of web.config file in the nuget package with your config file. The nuget package was a private package that I build and didn't realise this.

The web.config file in the package contained the binging redirects for MVC and this causes my config file to suddenly have duplicate entries. I initially missed it because it does all the binding redirects on one line.

Once you remove any duplicate binding redirects it fixes the problem. This question was big clue to me finding out what causes this.

like image 29
PBo Avatar answered Nov 03 '22 21:11

PBo