Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NUnit: Could not load assembly nunit.framework

Trying to execute a unit test which references nunit.framework fails:

System.IO.FileNotFoundException: Could not load file or assembly
'nunit.framework, Version=2.5.10.11092, Culture=neutral,
PublicKeyToken=96d09a1eb7f44a77' or one of its dependencies. The
system cannot find the file specified.

My scenario is the following:
Visual Studio 2010 TFS
C# and .NET Framewok v4.0
NUnit 2.6.0.12051

Detailed explanation:
I have a test project which references some dlls, one is nunit.framework.dll. This dll (nunit.framework.dll), points to the folder where nunit 2.6.0.12051 is installed. I execute NUnit (not from visual studio), through nunit-x86.exe and once lauched I load the test project(it is a class library, dll). Nunit tries to load but the error above explained appears.Test project compiles Ok, the dll is generated correctly. Also test project is targeting to .NET Framework v4.0.

like image 584
Ralph Avatar asked Dec 29 '12 12:12

Ralph


1 Answers

Please, try to redirect the assembly binding in your configuration file:

<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.6.0.12051" newVersion="2.6.0.12051"/>
        </dependentAssembly>
    </assemblyBinding>
</runtime>

You may have already a record like the above. In that case just adapt the "newVersion" value.

like image 99
Efstathios Chatzikyriakidis Avatar answered Nov 01 '22 01:11

Efstathios Chatzikyriakidis