NUnit与NHibernate崩溃

时间:2011-08-31 03:14:53

标签: nhibernate nunit

我正在使用NUnit运行一些NHibernate测试,而NUnit测试代理正在崩溃。我知道没有太多可以继续但显然NUnit本身不会崩溃。

这是堆栈跟踪...我不明白它尝试连接的服务器或原因,或者为什么NUnit本身崩溃。我猜这是我的.hbm文件的一个问题,因为NUnit在我的架构创建测试中崩溃了,它只包含这个:

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

对不起,我真的没有更多的信息 - 任何想法?

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
    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.

2 个答案:

答案 0 :(得分:2)

显然这是罪魁祸首:

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

执行此操作的代码已包含在包含AnEntityTypeInMyDomain的程序集中。 AddAssembly添加以.hbm.xml结尾的所有嵌入资源,这些资源位于给定程序集中。所以那些.hbm.xml文件被添加了两次。

我猜测某种情况导致堆栈溢出导致我发生Stack Overflow(hehe),因为这可以解释为什么NUnit崩溃,因为堆栈溢出没有转换为StackOverflowException。 / p>

我有点惊讶它没有检查是否已经添加了一个程序集......

让我修改一下:问题是堆栈溢出导致NUnit测试代理崩溃,导致NUnit测试运行器失去与代理的连接(解释了SocketException)。

现在,堆栈溢出的原因。在我的一些模型类的构造函数中,我分配了一个存储库类来获取关联实体的ID。现在,存储库类打开一个NHibernate会话;构建会话工厂分配模型类的实例......你可以看到它的发展方向。

所以我只是用另一种方法来关联另一个实体。

答案 1 :(得分:0)

看起来它试图使用远程处理来访问某个远程对象,但它失败了,因为远程对象(在本例中是本地的:127.0.0.1:30168)还没准备好与你的测试对话。

这是一个重复的问题(虽然没有回答): Nhibernate Error: BuidSessionFactory() Deadlock / Dropping Connection