Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 3635
  • Last Modified:

Visual Studio 2012/2013 GAC System.Web.MVC.dll Versions?

I recently installed VS 2013 on a dev computer which uses VS 2010/2012 versions. After successfully building and deploying a new VS 2013 project, I needed to update a prior VS 2012 project. It would not build, needs System.Web.MVC.dll  (v. 4.0.20710.0).

[Problem:]
The VS2013 replaced System.Web.MVC.dll  (v. 4.0.20710.0) with  (v. 4.0.40804.0).

[Attempted Solution:]
I took a VS2012 project backup and copied System.Web.MVC.dll  (v. 4.0.20710.0) into the web bin folder and referenced it and set Copy Local to true .

So now the VS2012 project builds and debugs great, just like it used to before installing VS2013.

[New Problem:]  
Now, when I publish the older file is overwritten with the newer System.Web.MVC.dll, which I don't want to use.

Q. Should I add the prior System.Web.MVC.dll (v. 4.0.20710.0) to the GAC?
Q. If so, how do I safely add it and keep both version?

I have never needed to change anything in the GAC before...
0
WorknHardr
Asked:
WorknHardr
  • 3
  • 2
1 Solution
 
Sammy AgeilCommented:
You shouldn't need to use the GAC.
You should be able to use  assembly binding for whatever version you want to use
Note that you also need System.Web.Abstractions,System.Web.Routing and System.Web.WebPages
<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <!-- … -->
  <system.web>
    <!-- … -->
    <compilation debug="true" targetFramework="4.0">
      <assemblies>
        <add assembly="System.Web.Mvc, Version=20710.0, Culture=neutral, PublicKeyToken=ADD_PUBLIC_TOKEN_KEY_HERE, processorArchitecture=MSIL" />
        <add assembly="System.Web.Abstractions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
        <add assembly="System.Web.Routing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
        <add assembly="System.Web.WebPages, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" />
      </assemblies>
    </compilation>
    <!-- … -->
  </system.web>
  <!-- … -->
</configuration>

Open in new window


Make sure to change the versions and public token keys in the config to match your assemblies versions and keys
you can identify the public token key by either using reflector or SN.exe http://msdn.microsoft.com/en-us/library/k5b5tt23%28VS.80%29.aspx
if you choose to use SN.EXE, this command will give you the public token key for the assembly "sn -T AssemblyName.dll"

Good luck
0
 
WorknHardrAuthor Commented:
I don't know exactly what changed in VS2012 projects after installing VS2013. I see other dev's on the Internet having similar difficulties too. I get this error on our Server 2012 IIS web host after publishing a VS2012 project:

     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. (Exception from HRESULT: 0x80131040)
0
 
WorknHardrAuthor Commented:
I noticed the System.Web.Mvc file version is now 4.0.0.1 instead of 4.0.0.0 as before. So I just changed the web.config to this and the web site error is gone:

    <dependentAssembly>
        <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.1" />
      </dependentAssembly>
0
 
Sammy AgeilCommented:
Glad you got it working
0
 
WorknHardrAuthor Commented:
Thx
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now