0

I'm getting one of these:

Could not load file or assembly 'System.Web.Mvc, Version=5.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) 

It continues:

=== Pre-bind state information ===
LOG: DisplayName = System.Web.Mvc, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
 (Fully-specified)
LOG: Appbase = file:///D:/Websites/Reporting/2016-02-18.2/
LOG: Initial PrivatePath = D:\Websites\Reporting\2016-02-18.2\bin
Calling assembly : (Unknown).
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: D:\Websites\Reporting\2016-02-18.2\web.config
LOG: Using host configuration file: C:\Windows\Microsoft.NET\Framework64\v4.0.30319\aspnet.config
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework64\v4.0.30319\config\machine.config.
LOG: Post-policy reference: System.Web.Mvc, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework64/v4.0.30319/Temporary ASP.NET Files/reports/7733280c/d5adf208/System.Web.Mvc.DLL.
LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework64/v4.0.30319/Temporary ASP.NET Files/reports/7733280c/d5adf208/System.Web.Mvc/System.Web.Mvc.DLL.
LOG: Attempting download of new URL file:///D:/Websites/Reporting/2016-02-18.2/bin/System.Web.Mvc.DLL.
WRN: Comparing the assembly name resulted in the mismatch: Minor Version
ERR: Failed to complete setup of assembly (hr = 0x80131040). Probing terminated.

The correct version of System.Web.Mvc is located in D:\Websites\Reporting\2016-02-18.2\bin. I've been fighting with this project all night, but I can't seem to get past this issue. For what it's worth, I do also have the binding redirect in the web.config.

  <dependentAssembly>
    <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
    <bindingRedirect oldVersion="0.0.0.0-5.2.3.0" newVersion="5.2.3.0" />
  </dependentAssembly>

I'm usually pretty good at dll hell type stuff, but this one has me puzzled because as far as I can tell it looks like it's telling me it can't find the file that's sitting in the bin directory and is the version it's looking for.

Where do I go from here?

EDIT: I should point out that it works fine in development and it also works fine when I deploy the project somewhere on the the development machine. But when I deploy to our staging server I am getting this. Not sure what could be different. I did have an issue at first where the TFS builds were grabbing the wrong dlls (even though I had copy local = true and the hint path was there it still grabbed incorrect versions and I had to delete the old nuget package folders to prevent this). I've been getting this error a lot, but this is the first time I got it and the file was actually the correct version when I checked it (and double, triple, and quadruple checked it).

BVernon
  • 3,205
  • 5
  • 28
  • 64
  • It sounds like you are binding to version 5.0.0.0 but you have version 5.x.?.? in the folder. Can you verify the version number of the file on disk? – lc. Feb 18 '16 at 08:09
  • @lc Yes that's true it's 5.2.3.0. But shouldn't the binding redirect which goes from 0 to 5.2.3.0 handle that? – BVernon Feb 18 '16 at 08:17
  • Yes it should. What's your binding redirect look like? – lc. Feb 18 '16 at 08:18
  • Just added it to the post – BVernon Feb 18 '16 at 08:25
  • Yep, definitely looks right to me :( – lc. Feb 18 '16 at 08:28
  • So weird because I can deploy to my dev machine and it runs fine, but not on the QA server. – BVernon Feb 18 '16 at 08:29
  • @lc. I finally got it working after updating the 5.0.0.0 references in the web.config in the Views folder to 5.2.3.0. But would you agree that it should have worked without me needing to do that if the binding redirect is in place? Just really curious why it works on dev but not QA. – BVernon Feb 18 '16 at 08:36
  • Agreed; I thought that was the whole point of the binding redirects. I wonder if someone else has an idea... – lc. Feb 18 '16 at 08:43

2 Answers2

0

I was using 5.0.0.0 in various places in the web.config in the Views folder. I don't understand why the binding redirect wouldn't take care of this issue but when I updated them to 5.2.3.0 it finally started working.

BVernon
  • 3,205
  • 5
  • 28
  • 64
0

The dll version in your path C:\Program Files (x86)\Microsoft ASP.NET\ASP.NET MVC 4\Assemblies\ must have the proper version. This is the where the application reads it (from the system). You got to update this, Else install the required version using Nuget which will update this location dll too. and for your comment I should point out that it works fine in development and it also works fine when I deploy the project somewhere on the the development machine. the reason is the dll version in the above mentioned path was what the application required, hence you didn't get any error.

Rajshekar Reddy
  • 18,647
  • 3
  • 40
  • 59
  • It doesn't reference the one in Program Files; it uses the one I got from Nuget which is the 5.2.3.0 version. I've verified that this is the version that gets copied to the bin folder when deployed. My understanding is that the binding redirect should redirect requests for any earlier version to use this version but for whatever reason that doesn't seem to work. As far as deployment on dev vs mo, they both have the 5.2.3.0 version in the bin directory so I don't see how that would be an issue unless I'm missing something here. – BVernon Feb 18 '16 at 23:08