«  Fullerscreen for Firefox | Architect Hubris »

Resolving Dependent .NET Assembly Version Conflicts

I ran into an interesting error message this morning while adding some NUnitAsp unit tests to Bloget.


------ Build started: Project: Bloget, Configuration: Debug Any CPU ------
Bloget -> D:\Data\Visual Studio 2005\Projects\Bloget\Bloget\bin\Debug\Bloget.dll
------ Build started: Project: D:\...\BlogetTest\, Configuration: Debug .NET ------
Validating Web Site

Validation Complete
------ Build started: Project: UnitTests, Configuration: Debug Any CPU ------
Consider app.config remapping of assembly "nunit.framework, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77" from Version "2.2.0.0" [] to Version "2.2.8.0" [C:\Program Files\TestDriven.NET 2.0\NUnit\nunit.framework.dll] to solve conflict and get rid of warning.
C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Microsoft.Common.targets : warning MSB3247: Found conflicts between different versions of the same dependent assembly.


I've highlighted the relevant bits here. This occurs because NUnitAsp depends on a different version of the NUnit framework than Test Driven .NET. I'm a bit fan of TDN but I also want to unit test the UI portions of Bloget which is what NUnitAsp does (more on this in another blog post). Fortunately, the error message gives you all you need to know to fix the problem. I added an App.config file to the project with the following XML.

<?xml version="1.0"?>
  <configuration>
    <runtime>
      <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
        <dependentAssembly>
          <assemblyIdentity name="nunit.framework" publicKeyToken="96D09A1EB7F44A77" culture="neutral"/>
          <bindingRedirect oldVersion="0.0.0.0-2.2.8.0" newVersion="2.2.8.0"/>
        </dependentAssembly>
      </assemblyBinding>
    </runtime>
  </configuration>

Having to enter this by hand is a real drag. But then I discovered an interesting shortcut. If you double-click on the warning message in Visual Studio 2005's Error List view, it will pop-up a nice little dialog like this:

One or more dependent assemblies have version conficts. Do you want to fix these conflicts by adding binding redirect records to the app.config?

(I run a Mac like theme on my laptop which is why the dialog does not look like Windows XP)

Once added, the build and run work as expected.

 

Comments

RE: Resolving Dependent .NET Assembly Version Conflicts
by Wayne Wainwright
Thursday, April 26, 2007 9:04 AM

THANK YOU! THANK YOU! THANK YOU!

I previously had NUnitAsp working (without this app.config fix), then my pc crashed, and when I tried to get it set back up on a new pc, i was having this issue. I've been working on this for a full day to no avail. I read every other post out there, any nothing worked (updating NUnit config files, re-installing versions of NUnit and NUnitAsp, etc. etc.)

Finally, when I attempted to run in debug mode (using TestDriven.NET); I noticed NUnitAsp was looking for a different version of NUnit (the old 2.2.0.0). But, even after installing the 2.2.0.0 dll, there was still an issue with the "publickeytoken" (DOH!).

I was about ready to give up when I came accross your post. I'm not a .Net expert, and never really mess with config files, so I never would have figured this out. Thank you again, and hopefully this will save others countless hours of hopelessness.


RE: Resolving Dependent .NET Assembly Version Conflicts
by Mike
Thursday, April 26, 2007 10:28 PM

Glad I could be of service :)


powered by Bloget™