NUnit crashes on .NET 4.0 x64 assemblies

Bug #566431 reported by Christoph Nahr
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
NUnit V2
Fix Committed
Undecided
Unassigned

Bug Description

NUnit 2.5.4 shows an error (NullReferenceException) when attempting to test .NET 4.0 assemblies built for AnyCPU (= running as x64 on my system). This is with the final release version of VS2010 on Vista 64, and affects both the GUI and the console runner. Attempting to do anything else in the GUI runner then causes a follow-up exception.

To fix, I had to edit the files nunit.exe.config and nunit-console.exe.config, adding the following line after the <configuration> tag in each file: <startup><requiredRuntime version="v4.0.30319" /></startup>

Peter Ritchie reports that .NET 4.0 assemblies do work if they were built for x86 and he used nunit-x86.exe, hence I assume that this problem is specific to x64 assemblies:
http://msmvps.com/blogs/peterritchie/archive/2010/04/18/getting-started-unit-testing-with-nunit.aspx

tags: added: 64-bit
Revision history for this message
Christoph Nahr (diogenes) wrote :

Peter Ritchie just responded to my blog comment and said that x86 assemblies ALSO required the manual requiredRuntime edit on his machine, and that x64 assemblies wouldn't work regardless.

For my part, I just tried running nunit-x86.exe on my machine with tests recompiled for x86. Without the requiredRuntime edit, I got the same error as in the 64-bit case. However, the 32-bit test worked fine once I added the same requiredRuntime edit to nunit-x86.exe.config as well.

So it would seem this isn't a 64-bit-specific error after all, but a general error with any .NET 4.0 assemblies.

tags: removed: 64-bit
Revision history for this message
Peter Ritchie (1-launchpad-peterritchie-com) wrote :
Download full text (7.6 KiB)

Okay. Here's a overview of what I'm doing:
Installed NUnit 2.5.4.10098.
Created new Class Library in Visual Studio 2010 RTM.
Added nunit.framework.dll to references.
Added [TestFixture] to a class, added a [Test] method to a new method. Built.
Ran nunit.exe
Dragged compiled class library DLL onto Nunit runner.
NullReferenceException occured. Detail from Tools\Exception Details

System.NullReferenceException...

Server stack trace:
   at NUnit.Util.ProcessRunner.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 [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.Core.ProxyTestRunner.Load(TestPackage package)
   at NUnit.Util.ProcessRunner.Load(TestPackage package)
   at NUnit.Util.TestLoader.LoadTest(String testName)

I then clicked the File menu to exit, then got an unhandled exception:
See the end of this message for details on invoking
just-in-time (JIT) debugging instead of this dialog box.

************** Exception Text **************
System.Net.Sockets.SocketException: An existing connection was forcibly closed by the remote host

Server stack trace:
   at System.Net.Sockets.Socket.Send(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags)
   at System.Runtime.Remoting.Channels.SocketStream.Write(Byte[] buffer, Int32 offset, Int32 count)
   at System.Runtime.Remoting.Channels.ChunkedMemoryStream.WriteTo(Stream stream)
   at System.Runtime.Remoting.Channels.Tcp.TcpClientSocketHandler.GetRequestStream(IMessage msg, Int32 contentLength, ITransportHeaders headers)
   at System.Runtime.Remoting.Channels.Tcp.TcpClientSocketHandler.SendRequest(IMessage msg, ITransportHeaders headers, Stream contentStream)
   at System.Runtime.Remoting.Channels.Tcp.TcpClientTransportSink.SendRequestWithRetry(IMessage msg, ITransportHeaders requestHeaders, Stream requestStream)
   at System.Runtime.Remoting.Channels.Tcp.TcpClientTransportSink.ProcessMessage(IMessage msg, ITransportHeaders requestHeaders, Stream requestStream, ITransportHeaders& responseHeaders, Stream& responseStream)
   at System.Runtime.Remoting.Channels.BinaryClientFormatterSink.SyncProcessMessage(IMessage msg)

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.get_Running()
   at NUnit.Core.ProxyTestRunner.get_Running()
   at NUnit.Util.TestLoader.get_Running()
   at NUnit.Gui.NUnitForm.get_IsTestRunning()
   at NUnit.Gui....

Read more...

Changed in nunitv2:
status: New → Fix Committed
Revision history for this message
Konstantin Trunin (konstantin-0) wrote :

We have the same problem under 2.6.3.13283
While there is no problem under 2.6.0.12051
Coul you please reopen the bug and fix it

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.