views:

468

answers:

1

Ok, so here's the full description of the problem I'm having:

I am trying to use NUnit ExtensionMethods but whenever I run a test containing one of the extension methods using TestDriven.Net or if I just flat out try to load the assembly using a test-runner GUI (Icarus or NUnit) I get a FileNotFoundException.

Pounding head against a wall and digging in further I think I know what's wrong. Cue reflector and yep, I can see that NUnit.Framework>ExtensionMethods.dll has a reference to

nunit.framework, Version=2.4.6.0, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77

and my current version of nunit that I'm including is

nunit.framework, Version=2.4.8.0, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77

Now I have never used assembly re-direction before but it seems like it would be a simple matter of adding an App.Config with the following lines:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
    <runtime>
        <assemblyBinding  xmlns="urn:schemas-microsoft-com:asm.v1">
            <dependentAssembly>
                <assemblyIdentity
                    name="nunit.framework.dll"
                    publicKeyToken="96d09a1eb7f44a77" />
                <bindingRedirect oldVersion="2.4.6.0" newVersion="2.4.8.0" />
            </dependentAssembly>
        </assemblyBinding>
    </runtime>
</configuration>

and it is my understanding that calls to the 2.4.6 version (which does not exist on this machine) should automatically redirect to the 2.4.8 version.

This does not work however, and I suspect (but have not yet confirmed) that this is because test runners do not automatically read app.config files.

So my question's are as follows:

  1. Am I right in my diagnosis of the problem?

  2. Is assembly redirection the appropriate solution and am I doing it right?

  3. How do I get this to work with the test runner?

+1  A: 

This should work if you put the configuration settings in the correct .config file. Which one that is depends on the environment you are using to run the tests, but both NUnit and TestDriven.NET should support using testassembly.dll.config.
As for this is the appropriate solution, I would say yes. The only other possibility would be to use a publisher policy file, but you would need the private key used to compile NUnit.

csgero
Thanks a lot, never heard of testassembly.dll.config but thats what I was looking for. In this case the NUnit Extensions is open source and only about 70 lines of code so I just opened and recompiled with my version. But this is good knowledge for next time.
George Mauer