5
votes

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].

3
Run nuget and update your asp.net MVC package. We had the same early this week due to an update on windows.Darren Wainwright
Thank's guy's. I actually just commented out the assembly line of code and changed the runtime binding code to look for v 3.0.0.1 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.Mat Amos
As far as I know and understand, the version number was changed to *.0.0.1 - so the Web config would be referencing an older *.0.0.0 library.Darren Wainwright
@Darren there is no web.config because its just an ordinary assembly containing a bunch of helper methods. But thanks, I just replaced the assembly references and now it compiles again. Thats BTW the first time that a Windows update broke a build.springy76

3 Answers

4
votes

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.

1
votes
  • 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?
1
votes

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.