Click here to Skip to main content
15,920,513 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)

I am trying to execute a NUnit test case (.Net 4.0 .dll, compiled against NUnit 2.5.9 ) using NUnit console in Windows 2008 R2 (X64) but it fails with below error message. Any idea?

System.Net.Sockets.SocketException: No connection could be made because the target machine actively refused it

Server stack trace:
   at System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress)
   at System.Net.Sockets.Socket.Connect(EndPoint remoteEP)
   at System.Runtime.Remoting.Channels.RemoteConnection.CreateNewSocket(EndPoint ipEndPoint)
   at System.Runtime.Remoting.Channels.RemoteConnection.CreateNewSocket()
   at System.Runtime.Remoting.Channels.SocketCache.GetSocket(String machinePortAndSid, Boolean openNew)
   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.NUnitForm.NUnitForm_Closing(Object sender, CancelEventArgs e)
   at System.Windows.Forms.Form.OnClosing(CancelEventArgs e)
   at System.Windows.Forms.Form.WmClose(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
   at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
Updated 18-Mar-11 7:39am

I don't know if this is possible, but I got this same error from NUnit when I actually had an infinite loop going in one of my tests.

I had some overloaded assert method that ended up looping back on itself. When I ran the code using the TestDriven.Net tool I saw the stack overflow exception that was causing Nunit to hang, and eventually return the error you mentioned.
Share this answer
Hi Eduard,

Thanks for your response.

Port number is changing all the time. Now it's 61137 and last time it was some thing else.
I am executing the DLL manually using NUnit in a single box..should I be checking the firewall even if the DLL is not calling any external services?

Share this answer
Eduard Keilholz 18-Mar-11 12:26pm    
I do think so, just try to switch it off for a brief moment. If your code works, you know the firewall is in your way, else you have to find the problem somewhere else.
Richard MacCutchan 18-Mar-11 13:41pm    
I don't think the firewall looks at messages on the loopback address.
Richard MacCutchan 18-Mar-11 13:42pm    
Are you sure you have a listener on this address?
Member 4545580 18-Mar-11 14:13pm    
ping doesn't work
but works fine.
Erhm, are you sure your firewall is switched off, or that you've created a rule in your firewall allowing communication over the given port 61137?
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900