开发者

NUnit crashing with NHibernate

开发者 https://www.devze.com 2023-04-01 02:33 出处:网络
I\'m running some NHibernate tests with NUnit and the NUnit test agent is crashing. I know there\'s not much to go on but obviously NUnit itself should not crash.

I'm running some NHibernate tests with NUnit and the NUnit test agent is crashing. I know there's not much to go on but obviously NUnit itself should not crash.

Here's the stack trace... I don't understand what server it's trying to connect to or why, or why NUnit itself is crashing. I'm guessing it's an issue with my .hbm files, as NUnit crashes on my schema creation test which just contains this:

var configuration = new Configuration();
configuration.Configure();
configuration.AddAssembly(typeof(AnEntityTypeInMyDomain).Assembly);
new SchemaExport(configuration).Execute(false, true, false);

Sorry I don't really have much more info - any ideas?

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: No connection could be made because the target machine actively refused it 127.0.0.1:30168

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.CancelRun()
   at System.Windows.Forms.Control.OnClick(EventArgs e)
   at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
   at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
   at System.Windows.Forms.Control.WndProc(Message& m)
   at System.Windows.Forms.ButtonBase.WndProc(Message& m)
   at System.Windows.Forms.Button.WndProc(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)


************** Loaded Assemblies **************
mscorlib
    Assembly Version: 2.0.0.0
    Win32 Version: 2.0.50727.5446 (Win7SP1GDR.050727-5400)
    CodeBase: file:///C:/Windows/Microsoft.NET/Framework64/v2.0.50727/mscorlib.dll
----------------------------------------
nunit
    Assembly Version: 2.5.10.11092
    Win32 Version: 2.5.10.11092
    CodeBase: file:///C:/Program%20Files%20(x86)/NUnit%202.5.10/bin/net-2.0/nunit.exe
----------------------------------------
nunit-gui-runner
    Assembly Version: 2.5.10.11092
    Win32 Version: 2.5.10.11092
    CodeBase: file:///C:/Program%20Files%20(x86)/NUnit%202.5.10/bin/net-2.0/lib/nunit-gui-runner.DLL
----------------------------------------
nunit.core
    Assembly Version: 2.5.10.11092
    Win32 Version: 2.5.10.11092
    CodeBase: file:///C:/Program%20Files%20(x86)/NUnit%202.5.10/bin/net-2.0/lib/nunit.core.DLL
----------------------------------------
nunit.util
    Assembly Version: 2.5.10.11092
    Win32 Version: 2.5.10.11092
    CodeBase: file:///C:/Program%20Files%20(x86)/NUnit%202.5.10/bin/net-2.0/lib/nunit.util.DLL
----------------------------------------
nunit.core.interfaces
    Assembly Version: 2.5.10.11092
    Win32 Version: 2.5.10.11092
    CodeBase: file:///C:/Program%20Files%20(x86)/NUnit%202.5.10/bin/net-2.0/lib/nunit.core.interfaces.DLL
----------------------------------------
nunit.uikit
    Assembly Version: 2.5.10.11092
    Win32 Version: 2.5.10.11092
    CodeBase: file:///C:/Program%20Files%20(x86)/NUnit%202.5.10/bin/net-2.0/lib/nunit.uikit.DLL
----------------------------------------
System
    Assembly Version: 2.0.0.0
    Win32 Version: 2.0.50727.5447 (Win7SP1GDR.050727-5400)
    CodeBase: file:///C:/Windows/assembly/GAC_MSIL/System/2.0.0.0__b77a5c561934e089/System.dll
----------------------------------------
System.Windows.Forms
    Assembly Version: 2.0.0.0
    Win32 Version: 2.0.50727.5446 (Win7SP1GDR.050727-5400)
    CodeBase: file:///C:/Windows/assembly/GAC_MSIL/System.Windows.Forms/2.0.0.0__b77a5c561934e089/System.Windows.Forms.dll
----------------------------------------
System.Drawing
    Assembly Version: 2.0.0.0
    Win32 Version: 2.0.50727.5420 (Win7SP1.050727-5400)
    CodeBase: file:///C:/Windows/assembly/GAC_MSIL/System.Drawing/2.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll
----------------------------------------
System.Configuration
    Assembly Version: 2.0.0.0
    Win32 Version: 2.0.50727.5420 (Win7SP1.050727-5400)
    CodeBase: file:///C:/Windows/assembly/GAC_MSIL/System.Configuration/2.0.0.0__b03f5f7f11d50a3a/System.Configuration.dll
----------------------------------------
System.Xml
    Assembly Version: 2.0.0.0
    Win32 Version: 2.0.50727.5420 (Win7SP1.050727-5400)
    CodeBase: file:///C:/Windows/assembly/GAC_MSIL/System.Xml/2.0.0.0__b77a5c561934e089/System.Xml.dll
----------------------------------------
System.Runtime.Remoting
    Assembly Version: 2.0.0.0
    Win32 Version: 2.0.50727.5420 (Win7SP1.050727-5400)
    CodeBase: file:///C:/Windows/assembly/GAC_MSIL/System.Runtime.Remoting/2.0.0.0__b77a5c561934e089/System.Runtime.Remoting.dll
----------------------------------------
nunit.uiexception
    Assembly Version: 2.5.10.11092
    Win32 Version: 2.5.10.11092
    CodeBase: file:///C:/Program%20Files%20(x86)/NUnit%202.5.10/bin/net-2.0/lib/nunit.uiexception.DLL
----------------------------------------
Accessibility开发者_JAVA百科
    Assembly Version: 2.0.0.0
    Win32 Version: 2.0.50727.4927 (NetFXspW7.050727-4900)
    CodeBase: file:///C:/Windows/assembly/GAC_MSIL/Accessibility/2.0.0.0__b03f5f7f11d50a3a/Accessibility.dll
----------------------------------------
System.Web
    Assembly Version: 2.0.0.0
    Win32 Version: 2.0.50727.5420 (Win7SP1.050727-5400)
    CodeBase: file:///C:/Windows/assembly/GAC_64/System.Web/2.0.0.0__b03f5f7f11d50a3a/System.Web.dll
----------------------------------------
mm7fptoa
    Assembly Version: 2.5.10.11092
    Win32 Version: 2.0.50727.5447 (Win7SP1GDR.050727-5400)
    CodeBase: file:///C:/Windows/assembly/GAC_MSIL/System/2.0.0.0__b77a5c561934e089/System.dll
----------------------------------------

************** JIT Debugging **************
To enable just-in-time (JIT) debugging, the .config file for this
application or computer (machine.config) must have the
jitDebugging value set in the system.windows.forms section.
The application must also be compiled with debugging
enabled.

For example:

<configuration>
    <system.windows.forms jitDebugging="true" />
</configuration>

When JIT debugging is enabled, any unhandled exception
will be sent to the JIT debugger registered on the computer
rather than be handled by this dialog box.


Apparently this was the culprit:

configuration.AddAssembly(typeof(AnEntityTypeInMyDomain).Assembly);

The code that was doing this was already in the assembly containing AnEntityTypeInMyDomain. AddAssembly adds all the embedded resources ending in .hbm.xml that are in the given assembly. So those .hbm.xml files were getting added twice.

I'm guessing that somehow led to a stack overflow which led me to Stack Overflow (hehe), as that would explain why NUnit was crashing, since the stack overflow wasn't transformed into a StackOverflowException.

I'm a bit surprised it doesn't check to see if an assembly's already been added...

Let me revise: the problem was a stack overflow that was crashing the NUnit test agent, causing the NUnit test runner to lose its connection to the agent (explains the SocketException).

Now, the cause of the stack overflow. In the constructors of some of my model classes, I was allocating a repository class to get an associated entity's ID. Now, the repository classes open an NHibernate session; building the session factory allocates instances of the model classes... you can see where this is going.

So I just used a different approach to associate the other entity.


Looks like it tries to access some remote object using remoting and it fails because the remote object (which is local in this case: 127.0.0.1:30168) is not ready to talk to your test.

Here's a duplicate question (not answered though): Nhibernate Error: BuidSessionFactory() Deadlock / Dropping Connection

0

精彩评论

暂无评论...
验证码 换一张
取 消