← Back to team overview

nunit-core team mailing list archive

[Bug 662937] Re: "Assembly Not Loaded" error, unhandled TypeLoadException

 

** Attachment added: "SampleApp Visual Studio solution"
   https://bugs.launchpad.net/bugs/662937/+attachment/1700452/+files/SampleApp.zip

-- 
"Assembly Not Loaded" error, unhandled TypeLoadException
https://bugs.launchpad.net/bugs/662937
You received this bug notification because you are a member of NUnit
Developers, which is subscribed to NUnit V2.

Status in NUnit V2 Test Framework: New

Bug description:
NUnit version 2.5.7.10213, GUI runner
Visual Studio 2010 Pro, no plugins

In a Visual Studio solution with 3 projects, NUnit sometimes crashes in the background while source code changes are being made.  The attached zip is a trimmed down SampleApp solution that you can use to reproduce the issue.

Steps to reproduce:
o VS2010 -> Load SampleApp solution. 
o NUnit -> Load SampleApp.nunit.
o NUnit -> Run all tests to ensure they pass.
o VS2010 -> Do the following steps to cause NUnit to crash with an 
    unhandled exception.

  o SampleApp project -> Actuator.cs -> change Actuate method signature
      from: 
        void Actuate();
      to: 
        void Actuate(int timesToActuate);

  o F6 to build.  This results in one build error as expected.

  o SampleApp project -> Client.cs -> change statement in Actuate method 
      from: 
            actuator.Actuate();
      to: 
            actuator.Actuate(timesToActuate);

  o F6 to build.  This results in another build error, and NUnit crashes.

  + NUnit crash message:
      Title: "Assembly Not Loaded"
      Message: "System.TypeLoadException : Method 'Actuate' in type
                'SampleApp.Mocks.MockActuator' from assembly
                'SampleApp.Mocks, Version=1.0.0.0, Culture=neutral,
                PublicKeyToken=null' does not have an implementation.
                
                For further information, use the Exception Details menu item."

  + NUnit Exception Details shows this additional info:
      System.TypeLoadException...
      
      Server stack trace: 
         at System.Reflection.RuntimeAssembly.GetExportedTypes(RuntimeAssembly assembly, ObjectHandleOnStack retTypes)
         at System.Reflection.RuntimeAssembly.GetExportedTypes()
         at NUnit.Core.CoreExtensions.InstallAdhocExtensions(Assembly assembly)
         at NUnit.Core.Builders.TestAssemblyBuilder.Load(String path)
         at NUnit.Core.Builders.TestAssemblyBuilder.Build(String assemblyName, Boolean autoSuites)
         at NUnit.Core.Builders.TestAssemblyBuilder.Build(String assemblyName, String testName, Boolean autoSuites)
         at NUnit.Core.TestSuiteBuilder.Build(TestPackage package)
         at NUnit.Core.SimpleTestRunner.Load(TestPackage package)
         at NUnit.Core.ProxyTestRunner.Load(TestPackage package)
         at NUnit.Core.ProxyTestRunner.Load(TestPackage package)
         at NUnit.Core.RemoteTestRunner.Load(TestPackage package)
         at System.Runtime.Remoting.Messaging.StackBuilderSink._PrivateProcessMessage(IntPtr md, Object[] args, Object server, Int32 methodPtr, Boolean fExecuteInContext, Object[]& outArgs)
         at System.Runtime.Remoting.Messaging.StackBuilderSink.SyncProcessMessage(IMessage msg, Int32 methodPtr, Boolean fExecuteInContext)
      
      Exception rethrown at [0]: 
         at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
         at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
         at NUnit.Core.TestRunner.Load(TestPackage package)
         at NUnit.Util.TestDomain.Load(TestPackage package)
         at NUnit.Core.ProxyTestRunner.Load(TestPackage package)
         at NUnit.Util.RemoteTestAgent.AgentRunner.Load(TestPackage package)
         at System.Runtime.Remoting.Messaging.StackBuilderSink._PrivateProcessMessage(IntPtr md, Object[] args, Object server, Int32 methodPtr, Boolean fExecuteInContext, Object[]& outArgs)
         at System.Runtime.Remoting.Messaging.StackBuilderSink.SyncProcessMessage(IMessage msg, Int32 methodPtr, Boolean fExecuteInContext)
      
      Exception rethrown at [1]: 
         at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
         at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
         at NUnit.Core.TestRunner.Load(TestPackage package)
         at NUnit.Core.ProxyTestRunner.Load(TestPackage package)
         at NUnit.Util.ProcessRunner.Load(TestPackage package)
         at NUnit.Util.TestLoader.ReloadTest(RuntimeFramework framework)

  o NUnit -> at this point opening the File menu or closing NUnit displays:
      "Unhandled exception has occurred in your application. If you click
       Continue, the application will ignore this error and attempt to continue.
       If you click Quit, the application will close immediately.
       
       No connection could be made because the target machine actively
       refused it 127.0.0.1:49900."
       
  o Running NUnit again without fixing the source code gets the same errors.
  o Changing Client.cs first and then Actuator.cs gets the same errors.
  
  + In all these cases MockActuatorTests.cs and MockActuator.cs are left
      unchanged.  They must be changed also (or first) in order to resolve
      or avoid the issue.

Let me know if I can provide additional information.

Regards
Joel





References