Search code examples
c#asp.netasp.net-mvcwindows-update

Handling references to System.Web.Mvc after security update


I am working on an ASP.NET MVC 3 solution (working in Visual Studio 2010) which references a specific version (3.0.0.0) of System.Web.Mvc in a number of projects.

This is done to allow the solution to build on machines that have later versions of MVC installed.

We fell victim to the security update to MVC released yesterday (System.Web.Mvc not functioning as expected after Windows Update) where the System.Web.Mvc DLL version was incremented to 3.0.0.1

This can easily be fixed on my development machine.

My question is if I change each project referencing System.Web.Mvc to build using 3.0.0.1 and then deploy to a server that still has 3.0.0.0 in the GAC will my application still work OK?

I'm aware there are ways of including the MVC DLLs as part of the deployment but I want to make as few changes as possible to the current build/deploy process.


Solution

  • Try adding the following to the <runtime> element in your Web.config

    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35"/>
        <bindingRedirect oldVersion="0.0.0.0-3.0.0.1" newVersion="3.0.0.0"/>
      </dependentAssembly>
    </assemblyBinding>
    

    Not tested, but this should work.