Solved

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

Posted on 2014-10-21
5
3,336 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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

772 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