Solved

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

Posted on 2014-10-21
5
3,229 Views
Last Modified: 2014-10-21
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
Comment
Question by:WorknHardr
  • 3
  • 2
5 Comments
 
LVL 27

Accepted Solution

by:
Sammy earned 500 total points
ID: 40394520
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
 

Author Comment

by:WorknHardr
ID: 40394552
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
 

Author Comment

by:WorknHardr
ID: 40394566
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
 
LVL 27

Expert Comment

by:Sammy
ID: 40394594
Glad you got it working
0
 

Author Closing Comment

by:WorknHardr
ID: 40394664
Thx
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now