3
votes

Assembly 'dllname.Moles, Version=1.2.0.0, Culture=neutral, PublicKeyToken=null' uses 'System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' which has a higher version than referenced assembly 'System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'

A MVC3 solution targetting the .NET4.0 framework, with a unittest project using the Moles framework, worked perfectly in Visual Studio 2010. MVC4 was not installed on this computer.

After installation of Visual Studio 2012 (and the mandatory in place replacement of .NET4.0 by .NET4.5 and the installation of MVC4), the unittest project doesn't compile anymore in VS2010, it complains about the given error.

When we inspect the assembly, we see effectively that it is referencing MVC4 and MVC3??

  • BoneSoft.CSS, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
  • itextsharp, Version=5.1.2.0, Culture=neutral, PublicKeyToken=8354ae6d2174ddca
  • Microsoft.ExtendedReflection, Version=0.94.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
  • Microsoft.Moles.Framework, Version=0.94.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
  • mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
  • mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
  • NHibernate.Validator, Version=1.3.1.4000, Culture=neutral, PublicKeyToken=70154e18752585bd
  • System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
  • System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
  • System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
  • System.Data, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
  • System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
  • System.Runtime.Caching, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
  • System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
  • System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
  • System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
  • System.Xml, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089

MVC4 is never referenced in the whole solution, but Moles somewhere thinks it must be included when generating a 'moles assembly' of a assembly who is referencing MVC3.

I have also moles assemblies of other assemblies who are not referencing MVC3 and there no problem at compiling time.

I deleted already the moles assembly in the project, rebuilded and recreated the moles assembly: same error.

Ideas where to search the problem?

2

2 Answers

0
votes

When you installed VS 2012, it installed MVC4 on the box. MVC 3 wont work well SxS with MVC 4. You need to update MVC 3 app to work on machine where MVC 4 is installed.
This is documented in release notes for MVC 4.0. Please read section Installing ASP.NET MVC 4 breaks ASP.NET MVC 3 RTM applications. Follow setps "Required updates".

0
votes

I was getting a similar error on a project so I removed the reference to MVC and re-added the reference to MVC 3, then I was able to compile.

Looking at the .csproj file, before it read:

<Reference Include="System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
  <SpecificVersion>False</SpecificVersion>
  <Private>False</Private>
</Reference>

and after re-adding the reference:

<Reference Include="System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" />

So it looks like the tag <SpecificVersion>False</SpecificVersion> was letting the project look for the reference to the newer version of MVC, which was causing the version conflict.