← Back to team overview

nunit-core team mailing list archive

[Bug 595683] Re: NUnit console runner fails to load assemblies

 

The change you have made is actually what the TODO comment is talking
about. At some past time, loading by AssemblyName rather than by the
string name of the file caused failures. Whatever the cause was, it
seems to be gone now. I'm able to change this code in both 2.5 and 3.0
and everything works OK.

So I understand this better, what's different about your assembly name -
i.e. is there a key, a non-default culture, etc?

** Also affects: nunitv2
   Importance: Undecided
       Status: New

** Changed in: nunitv2
       Status: New => Triaged

** Changed in: nunit-3.0
       Status: New => Triaged

** Changed in: nunitv2
   Importance: Undecided => Medium

** Changed in: nunit-3.0
   Importance: Undecided => Medium

** Changed in: nunit-3.0
     Assignee: (unassigned) => Charlie Poole (charlie.poole)

** Changed in: nunitv2
     Assignee: (unassigned) => Charlie Poole (charlie.poole)

** Changed in: nunit-3.0
    Milestone: None => 2.9.5

-- 
NUnit console runner fails to load assemblies
https://bugs.launchpad.net/bugs/595683
You received this bug notification because you are a member of NUnit
Developers, which is subscribed to NUnit V2.

Status in NUnit Test Framework: Triaged
Status in NUnit V2 Test Framework: Triaged

Bug description:
I am using NUnit 2.9.4 which I have downloaded as source and compiled with VS2010 RC.
I had trouble loading my test assemblies running the test-runner.exe gives the following output:

----------------------------------------------------------------------------------------------------------------------

PS C:\projects\Specs\Specs.Test\bin\Debug> ..\..\..\..\NUnit\NUnit-2.9.4\solutions\vs2010\bin\Debug\test-runner.exe .\Specs.Test.dll
TestRunner version 1.0.0
Copyright c  2009 Charlie Poole

Runtime Environment -
    OS Version: Microsoft Windows NT 5.1.2600 Service Pack 3
  .NET Version: 4.0.30128.1

Options -
    Use Same AppDomain

Could not load file or assembly 'Specs.Test' or one of its dependencies. The system cannot find the file specified.
PS C:\projects\Specs\Specs.Test\bin\Debug>

----------------------------------------------------------------------------------------------------------------------------

If I change the method Load on the class DefaultTestAssemblyBuilder in the file NUnit-2.9.4\src\framework\Internal\DefaultTestAssemblyBuilder.cs from 


        private Assembly Load(string path)
        {
            Assembly assembly = null;

            // Throws if this isn't a managed assembly or if it was built
            // with a later version of the same assembly.
            AssemblyName assemblyName = AssemblyName.GetAssemblyName(Path.GetFileName(path));

            // TODO: Figure out why we can't load using the assembly name
            // in all cases. Might be a problem with the tests themselves.
            assembly = Assembly.Load(Path.GetFileNameWithoutExtension(path));

            if (assembly != null)
                CoreExtensions.Host.InstallAdhocExtensions(assembly);

            InternalTrace.Info("Loaded assembly " + assembly.FullName);

            return assembly;
        }


to


        private Assembly Load(string path)
        {
            Assembly assembly = null;

            // Throws if this isn't a managed assembly or if it was built
            // with a later version of the same assembly.
            AssemblyName assemblyName = AssemblyName.GetAssemblyName(Path.GetFileName(path));

            // TODO: Figure out why we can't load using the assembly name
            // in all cases. Might be a problem with the tests themselves.
            assembly = Assembly.Load(assemblyName);

            if (assembly != null)
                CoreExtensions.Host.InstallAdhocExtensions(assembly);

            InternalTrace.Info("Loaded assembly " + assembly.FullName);

            return assembly;
        }


I can load my assemblies. -The difference in the code is that the Assembly.Load call takes the AssemblyName instead of the path.
With the code change the test-runner output is:

PS C:\projects\Specs\Specs.Test\bin\Debug> ..\..\..\..\NUnit\NUnit-2.9.4\solutions\vs2010\bin\Debug\test-runner.exe .\Specs.Test.dll
TestRunner version 1.0.0
Copyright c  2009 Charlie Poole

Runtime Environment -
    OS Version: Microsoft Windows NT 5.1.2600 Service Pack 3
  .NET Version: 4.0.30128.1

Options -
    Use Same AppDomain


   Tests run: 6, Errors: 0, Failures: 0, Inconclusive: 0
     Not run: 0, Invalid: 0, Ignored: 0, Skipped: 0
        Time: 0,031 seconds

PS C:\projects\Specs\Specs.Test\bin\Debug>





References