Nhibernate 错误:BuidSessionFactory() 死锁/断开连接
下午好,
我已经在这个问题上困扰了好几天了,我觉得我对 Nhibernate / SQL Server 的理解还不足以让我弄清楚。
问题是,任何涉及调用以下内容的单元测试
Nhibernate.Cfg.Configuaration.BuildSessionFactory();
都会陷入运行状态,我被迫按“停止”以使 NUnit 做出响应。此时会出现一个错误对话框,其中包含以下信息:
“无法建立连接,因为目标计算机主动拒绝它”,
并显示“异常文本”;
System.Net.Sockets.SocketException: No connection could be made because the target machine actively refused it 127.0.0.1:51293
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)
我的 NHibernate 是这样配置的;
<hibernate-configuration xmlns="urn:nhibernate-configuration-2.2">
<session-factory>
<property name="connection.provider">NHibernate.Connection.DriverConnectionProvider</property>
<property name="dialect">NHibernate.Dialect.MsSql2008Dialect</property>
<property name="connection.driver_class">NHibernate.Driver.SqlClientDriver</property>
<property name="connection.connection_string">Server=MachineName\SQLEXPRESS;database=TestingDB;Integrated Security=true;</property>
<property name ="proxyfactory.factory_class">NHibernate.ByteCode.LinFu.ProxyFactoryFactory, Nhibernate.ByteCode.LinFu</property>
<property name="show_sql">true</property>
</session-factory>
</hibernate-configuration>
并使用 TestFixtureSetup 调用以下内容:
_configuration.Configure();
_configuration.AddAssembly(typeof(MyClass).Assembly);
_sessionFactory = _configuration.BuildSessionFactory();
测试只是挂在最后一行。为了尝试了解出了什么问题,我启用了 log4net,它在运行测试时给出了以下输出。
[TestRunnerThread] INFO NHibernate.Cfg.Environment - NHibernate 2.1.2.4000 (2.1.2.4000)
[TestRunnerThread] INFO NHibernate.Cfg.Environment - hibernate-configuration section not found in application configuration file
[TestRunnerThread] INFO NHibernate.Cfg.Environment - Bytecode provider name : lcg
[TestRunnerThread] INFO NHibernate.Cfg.Environment - Using reflection optimizer
[TestRunnerThread] DEBUG NHibernate.Cfg.Configuration - connection.provider=NHibernate.Connection.DriverConnectionProvider
[TestRunnerThread] DEBUG NHibernate.Cfg.Configuration - dialect=NHibernate.Dialect.MsSql2008Dialect
[TestRunnerThread] DEBUG NHibernate.Cfg.Configuration - connection.driver_class=NHibernate.Driver.SqlClientDriver
[TestRunnerThread] DEBUG NHibernate.Cfg.Configuration - connection.connection_string=Server=MachineName\SQLEXPRESS;database=MySolution_Testing;Integrated Security=true;
[TestRunnerThread] DEBUG NHibernate.Cfg.Configuration - proxyfactory.factory_class=NHibernate.ByteCode.LinFu.ProxyFactoryFactory, Nhibernate.ByteCode.LinFu
[TestRunnerThread] DEBUG NHibernate.Cfg.Configuration - show_sql=true
[TestRunnerThread] DEBUG NHibernate.Cfg.Configuration - properties: System.Collections.Generic.Dictionary`2[System.String,System.String]
[TestRunnerThread] INFO NHibernate.Cfg.Configuration - Mapping resource: MySolution.Models.Mappings.MenuItem.hbm.xml
[TestRunnerThread] INFO NHibernate.Dialect.Dialect - Using dialect: NHibernate.Dialect.MsSql2008Dialect
[TestRunnerThread] INFO NHibernate.Cfg.XmlHbmBinding.Binder - Mapping class: MySolution.Models.MenuItem -> MenuItems
[TestRunnerThread] DEBUG NHibernate.Cfg.XmlHbmBinding.Binder - Mapped property: ID -> MenuItemID, type: Int32
[TestRunnerThread] DEBUG NHibernate.Cfg.XmlHbmBinding.Binder - Mapped property: Name -> MenuItemName, type: String
[TestRunnerThread] DEBUG NHibernate.Cfg.XmlHbmBinding.Binder - Mapped property: ControllerName -> MenuItemController, type: String
[TestRunnerThread] DEBUG NHibernate.Cfg.XmlHbmBinding.Binder - Mapped property: ActionName -> MenuItemAction, type: String
[TestRunnerThread] INFO NHibernate.Cfg.Configuration - Mapping resource: MySolution.Models.Mappings.Perspective.hbm.xml
[TestRunnerThread] INFO NHibernate.Dialect.Dialect - Using dialect: NHibernate.Dialect.MsSql2008Dialect
[TestRunnerThread] INFO NHibernate.Cfg.XmlHbmBinding.Binder - Mapping class: MySolution.Models.UserPerspective -> Perspectives
[TestRunnerThread] DEBUG NHibernate.Cfg.XmlHbmBinding.Binder - Mapped property: ID -> PerspectiveID, type: Int32
[TestRunnerThread] DEBUG NHibernate.Cfg.XmlHbmBinding.Binder - Mapped property: Name -> PerspectiveName, type: String
[TestRunnerThread] DEBUG NHibernate.Cfg.XmlHbmBinding.Binder - Mapped property: Description -> PerspectiveDescription, type: String
[TestRunnerThread] DEBUG NHibernate.Cfg.XmlHbmBinding.Binder - Mapped property: Password -> PerspectivePassword, type: String
[TestRunnerThread] INFO NHibernate.Cfg.Configuration - Mapping resource: MySolution.Models.Mappings.ViewGroup.hbm.xml
[TestRunnerThread] INFO NHibernate.Dialect.Dialect - Using dialect: NHibernate.Dialect.MsSql2008Dialect
[TestRunnerThread] INFO NHibernate.Cfg.XmlHbmBinding.Binder - Mapping class: MySolution.Models.ViewGroup -> ViewGroups
[TestRunnerThread] DEBUG NHibernate.Cfg.XmlHbmBinding.Binder - Mapped property: ID -> ViewGroupID, type: Int32
[TestRunnerThread] DEBUG NHibernate.Cfg.XmlHbmBinding.Binder - Mapped property: Perspective -> Link_PerspectiveID, type: MySolution.Models.UserPerspective
[TestRunnerThread] DEBUG NHibernate.Cfg.XmlHbmBinding.Binder - Mapped property: MenuItems, type: Iesi.Collections.Generic.ISet`1[[MySolution.Models.MenuItem, MySolution.Models, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]](MySolution.Models.ViewGroup.MenuItems)
[TestRunnerThread] INFO NHibernate.Cfg.Configuration - checking mappings queue
[TestRunnerThread] INFO NHibernate.Cfg.Configuration - processing one-to-many association mappings
[TestRunnerThread] DEBUG NHibernate.Cfg.XmlHbmBinding.Binder - Second pass for collection: MySolution.Models.ViewGroup.MenuItems
[TestRunnerThread] INFO NHibernate.Cfg.XmlHbmBinding.Binder - mapping collection: MySolution.Models.ViewGroup.MenuItems -> MenuItems
[TestRunnerThread] DEBUG NHibernate.Cfg.XmlHbmBinding.Binder - Mapped collection key: MenuItemID, one-to-many: MySolution.Models.MenuItem
[TestRunnerThread] INFO NHibernate.Cfg.Configuration - processing one-to-one association property references
[TestRunnerThread] INFO NHibernate.Cfg.Configuration - processing foreign key constraints
[TestRunnerThread] DEBUG NHibernate.Cfg.Configuration - resolving reference to class: MySolution.Models.ViewGroup
[TestRunnerThread] DEBUG NHibernate.Cfg.Configuration - resolving reference to class: MySolution.Models.UserPerspective
[TestRunnerThread] INFO NHibernate.Cfg.Configuration - processing filters (second pass)
[TestRunnerThread] INFO NHibernate.Dialect.Dialect - Using dialect: NHibernate.Dialect.MsSql2008Dialect
[TestRunnerThread] INFO NHibernate.Exceptions.SQLExceptionConverterFactory - Using dialect defined converter
[TestRunnerThread] INFO NHibernate.Cfg.SettingsFactory - Generate SQL with comments: disabled
[TestRunnerThread] INFO NHibernate.Connection.ConnectionProviderFactory - Initializing connection provider: NHibernate.Connection.DriverConnectionProvider
[TestRunnerThread] INFO NHibernate.Connection.ConnectionProvider - Configuring ConnectionProvider
[TestRunnerThread] INFO NHibernate.Cfg.SettingsFactory - Transaction factory: NHibernate.Transaction.AdoNetWithDistrubtedTransactionFactory
[TestRunnerThread] INFO NHibernate.Cfg.SettingsFactory - Optimize cache for minimal puts: False
[TestRunnerThread] INFO NHibernate.Cfg.SettingsFactory - Connection release mode: auto
[TestRunnerThread] INFO NHibernate.Cfg.SettingsFactory - Default batch fetch size: 1
[TestRunnerThread] INFO NHibernate.Cfg.SettingsFactory - echoing all SQL to stdout
[TestRunnerThread] INFO NHibernate.Cfg.SettingsFactory - Statistics: disabled
[TestRunnerThread] INFO NHibernate.Cfg.SettingsFactory - Deleted entity synthetic identifier rollback: disabled
[TestRunnerThread] INFO NHibernate.Cfg.SettingsFactory - Query translator: NHibernate.Hql.Ast.ANTLR.ASTQueryTranslatorFactory
[TestRunnerThread] INFO NHibernate.Cfg.SettingsFactory - Query language substitutions: {}
[TestRunnerThread] INFO NHibernate.Cfg.SettingsFactory - cache provider: NHibernate.Cache.NoCacheProvider, NHibernate, Version=2.1.2.4000, Culture=neutral, PublicKeyToken=aa95f207798dfdb4
[TestRunnerThread] DEBUG NHibernate.Cfg.SettingsFactory - Wrap result sets: disabled
[TestRunnerThread] INFO NHibernate.Cfg.SettingsFactory - Batcher factory: NHibernate.AdoNet.NonBatchingBatcherFactory, NHibernate, Version=2.1.2.4000, Culture=neutral, PublicKeyToken=aa95f207798dfdb4
[TestRunnerThread] INFO NHibernate.Cfg.SettingsFactory - Default entity-mode: Poco
[TestRunnerThread] INFO NHibernate.Cfg.SettingsFactory - Named query checking : enabled
[TestRunnerThread] INFO NHibernate.Impl.SessionFactoryImpl - building session factory
[TestRunnerThread] DEBUG NHibernate.Impl.SessionFactoryImpl - Session factory constructed with filter configurations : {}
[TestRunnerThread] DEBUG NHibernate.Impl.SessionFactoryImpl - instantiating session factory with properties: {'use_reflection_optimizer'='True', 'connection.provider'='NHibernate.Connection.DriverConnectionProvider', 'dialect'='NHibernate.Dialect.MsSql2008Dialect', 'connection.driver_class'='NHibernate.Driver.SqlClientDriver', 'connection.connection_string'='Server=MachineName\SQLEXPRESS;database=MySolution_Testing;Integrated Security=true;', 'proxyfactory.factory_class'='NHibernate.ByteCode.LinFu.ProxyFactoryFactory, Nhibernate.ByteCode.LinFu', 'show_sql'='true'}
[TestRunnerThread] DEBUG NHibernate.Connection.DriverConnectionProvider - Obtaining IDbConnection from Driver
[TestRunnerThread] DEBUG NHibernate.Connection.ConnectionProvider - Closing connection
正如你所看到的,NHibernate 似乎正确地配置了它自己,但是,最后两行似乎表明,当实际请求连接时,出现了一些错误,并且全部被关闭。这不会报告回 NUnit,因此它只是坐在那里无限期地等待使用有效的连接。
我还有其他使用 Fluent 配置的项目,这些项目似乎运行正常,但这些较旧的项目使用 SQL Compact 数据库而不是 SQL Express。
有人能够建议解决这个问题吗?
感谢您抽出时间。
Good afternoon,
I have been stuck on this issue for a number of days now and I don't feel my understanding of Nhibernate / SQL Server is of enough so that I might figure it out.
The issue is that any unit test that involves making a call to:
Nhibernate.Cfg.Configuaration.BuildSessionFactory();
Just becomes stuck in a running state, I am forced to press 'Stop' in order to get NUnit to respond. At which point an error dialogue appears with the following information:
"No connection could be made because the target machine actively refused it"
With the "exception text" being;
System.Net.Sockets.SocketException: No connection could be made because the target machine actively refused it 127.0.0.1:51293
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)
My NHibernate is configured like so;
<hibernate-configuration xmlns="urn:nhibernate-configuration-2.2">
<session-factory>
<property name="connection.provider">NHibernate.Connection.DriverConnectionProvider</property>
<property name="dialect">NHibernate.Dialect.MsSql2008Dialect</property>
<property name="connection.driver_class">NHibernate.Driver.SqlClientDriver</property>
<property name="connection.connection_string">Server=MachineName\SQLEXPRESS;database=TestingDB;Integrated Security=true;</property>
<property name ="proxyfactory.factory_class">NHibernate.ByteCode.LinFu.ProxyFactoryFactory, Nhibernate.ByteCode.LinFu</property>
<property name="show_sql">true</property>
</session-factory>
</hibernate-configuration>
and with the TestFixtureSetup calling the following:
_configuration.Configure();
_configuration.AddAssembly(typeof(MyClass).Assembly);
_sessionFactory = _configuration.BuildSessionFactory();
The test simply hangs on the final line. To try and understand what is going wrong, I enabled log4net which gave the following output when running a test.
[TestRunnerThread] INFO NHibernate.Cfg.Environment - NHibernate 2.1.2.4000 (2.1.2.4000)
[TestRunnerThread] INFO NHibernate.Cfg.Environment - hibernate-configuration section not found in application configuration file
[TestRunnerThread] INFO NHibernate.Cfg.Environment - Bytecode provider name : lcg
[TestRunnerThread] INFO NHibernate.Cfg.Environment - Using reflection optimizer
[TestRunnerThread] DEBUG NHibernate.Cfg.Configuration - connection.provider=NHibernate.Connection.DriverConnectionProvider
[TestRunnerThread] DEBUG NHibernate.Cfg.Configuration - dialect=NHibernate.Dialect.MsSql2008Dialect
[TestRunnerThread] DEBUG NHibernate.Cfg.Configuration - connection.driver_class=NHibernate.Driver.SqlClientDriver
[TestRunnerThread] DEBUG NHibernate.Cfg.Configuration - connection.connection_string=Server=MachineName\SQLEXPRESS;database=MySolution_Testing;Integrated Security=true;
[TestRunnerThread] DEBUG NHibernate.Cfg.Configuration - proxyfactory.factory_class=NHibernate.ByteCode.LinFu.ProxyFactoryFactory, Nhibernate.ByteCode.LinFu
[TestRunnerThread] DEBUG NHibernate.Cfg.Configuration - show_sql=true
[TestRunnerThread] DEBUG NHibernate.Cfg.Configuration - properties: System.Collections.Generic.Dictionary`2[System.String,System.String]
[TestRunnerThread] INFO NHibernate.Cfg.Configuration - Mapping resource: MySolution.Models.Mappings.MenuItem.hbm.xml
[TestRunnerThread] INFO NHibernate.Dialect.Dialect - Using dialect: NHibernate.Dialect.MsSql2008Dialect
[TestRunnerThread] INFO NHibernate.Cfg.XmlHbmBinding.Binder - Mapping class: MySolution.Models.MenuItem -> MenuItems
[TestRunnerThread] DEBUG NHibernate.Cfg.XmlHbmBinding.Binder - Mapped property: ID -> MenuItemID, type: Int32
[TestRunnerThread] DEBUG NHibernate.Cfg.XmlHbmBinding.Binder - Mapped property: Name -> MenuItemName, type: String
[TestRunnerThread] DEBUG NHibernate.Cfg.XmlHbmBinding.Binder - Mapped property: ControllerName -> MenuItemController, type: String
[TestRunnerThread] DEBUG NHibernate.Cfg.XmlHbmBinding.Binder - Mapped property: ActionName -> MenuItemAction, type: String
[TestRunnerThread] INFO NHibernate.Cfg.Configuration - Mapping resource: MySolution.Models.Mappings.Perspective.hbm.xml
[TestRunnerThread] INFO NHibernate.Dialect.Dialect - Using dialect: NHibernate.Dialect.MsSql2008Dialect
[TestRunnerThread] INFO NHibernate.Cfg.XmlHbmBinding.Binder - Mapping class: MySolution.Models.UserPerspective -> Perspectives
[TestRunnerThread] DEBUG NHibernate.Cfg.XmlHbmBinding.Binder - Mapped property: ID -> PerspectiveID, type: Int32
[TestRunnerThread] DEBUG NHibernate.Cfg.XmlHbmBinding.Binder - Mapped property: Name -> PerspectiveName, type: String
[TestRunnerThread] DEBUG NHibernate.Cfg.XmlHbmBinding.Binder - Mapped property: Description -> PerspectiveDescription, type: String
[TestRunnerThread] DEBUG NHibernate.Cfg.XmlHbmBinding.Binder - Mapped property: Password -> PerspectivePassword, type: String
[TestRunnerThread] INFO NHibernate.Cfg.Configuration - Mapping resource: MySolution.Models.Mappings.ViewGroup.hbm.xml
[TestRunnerThread] INFO NHibernate.Dialect.Dialect - Using dialect: NHibernate.Dialect.MsSql2008Dialect
[TestRunnerThread] INFO NHibernate.Cfg.XmlHbmBinding.Binder - Mapping class: MySolution.Models.ViewGroup -> ViewGroups
[TestRunnerThread] DEBUG NHibernate.Cfg.XmlHbmBinding.Binder - Mapped property: ID -> ViewGroupID, type: Int32
[TestRunnerThread] DEBUG NHibernate.Cfg.XmlHbmBinding.Binder - Mapped property: Perspective -> Link_PerspectiveID, type: MySolution.Models.UserPerspective
[TestRunnerThread] DEBUG NHibernate.Cfg.XmlHbmBinding.Binder - Mapped property: MenuItems, type: Iesi.Collections.Generic.ISet`1[[MySolution.Models.MenuItem, MySolution.Models, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]](MySolution.Models.ViewGroup.MenuItems)
[TestRunnerThread] INFO NHibernate.Cfg.Configuration - checking mappings queue
[TestRunnerThread] INFO NHibernate.Cfg.Configuration - processing one-to-many association mappings
[TestRunnerThread] DEBUG NHibernate.Cfg.XmlHbmBinding.Binder - Second pass for collection: MySolution.Models.ViewGroup.MenuItems
[TestRunnerThread] INFO NHibernate.Cfg.XmlHbmBinding.Binder - mapping collection: MySolution.Models.ViewGroup.MenuItems -> MenuItems
[TestRunnerThread] DEBUG NHibernate.Cfg.XmlHbmBinding.Binder - Mapped collection key: MenuItemID, one-to-many: MySolution.Models.MenuItem
[TestRunnerThread] INFO NHibernate.Cfg.Configuration - processing one-to-one association property references
[TestRunnerThread] INFO NHibernate.Cfg.Configuration - processing foreign key constraints
[TestRunnerThread] DEBUG NHibernate.Cfg.Configuration - resolving reference to class: MySolution.Models.ViewGroup
[TestRunnerThread] DEBUG NHibernate.Cfg.Configuration - resolving reference to class: MySolution.Models.UserPerspective
[TestRunnerThread] INFO NHibernate.Cfg.Configuration - processing filters (second pass)
[TestRunnerThread] INFO NHibernate.Dialect.Dialect - Using dialect: NHibernate.Dialect.MsSql2008Dialect
[TestRunnerThread] INFO NHibernate.Exceptions.SQLExceptionConverterFactory - Using dialect defined converter
[TestRunnerThread] INFO NHibernate.Cfg.SettingsFactory - Generate SQL with comments: disabled
[TestRunnerThread] INFO NHibernate.Connection.ConnectionProviderFactory - Initializing connection provider: NHibernate.Connection.DriverConnectionProvider
[TestRunnerThread] INFO NHibernate.Connection.ConnectionProvider - Configuring ConnectionProvider
[TestRunnerThread] INFO NHibernate.Cfg.SettingsFactory - Transaction factory: NHibernate.Transaction.AdoNetWithDistrubtedTransactionFactory
[TestRunnerThread] INFO NHibernate.Cfg.SettingsFactory - Optimize cache for minimal puts: False
[TestRunnerThread] INFO NHibernate.Cfg.SettingsFactory - Connection release mode: auto
[TestRunnerThread] INFO NHibernate.Cfg.SettingsFactory - Default batch fetch size: 1
[TestRunnerThread] INFO NHibernate.Cfg.SettingsFactory - echoing all SQL to stdout
[TestRunnerThread] INFO NHibernate.Cfg.SettingsFactory - Statistics: disabled
[TestRunnerThread] INFO NHibernate.Cfg.SettingsFactory - Deleted entity synthetic identifier rollback: disabled
[TestRunnerThread] INFO NHibernate.Cfg.SettingsFactory - Query translator: NHibernate.Hql.Ast.ANTLR.ASTQueryTranslatorFactory
[TestRunnerThread] INFO NHibernate.Cfg.SettingsFactory - Query language substitutions: {}
[TestRunnerThread] INFO NHibernate.Cfg.SettingsFactory - cache provider: NHibernate.Cache.NoCacheProvider, NHibernate, Version=2.1.2.4000, Culture=neutral, PublicKeyToken=aa95f207798dfdb4
[TestRunnerThread] DEBUG NHibernate.Cfg.SettingsFactory - Wrap result sets: disabled
[TestRunnerThread] INFO NHibernate.Cfg.SettingsFactory - Batcher factory: NHibernate.AdoNet.NonBatchingBatcherFactory, NHibernate, Version=2.1.2.4000, Culture=neutral, PublicKeyToken=aa95f207798dfdb4
[TestRunnerThread] INFO NHibernate.Cfg.SettingsFactory - Default entity-mode: Poco
[TestRunnerThread] INFO NHibernate.Cfg.SettingsFactory - Named query checking : enabled
[TestRunnerThread] INFO NHibernate.Impl.SessionFactoryImpl - building session factory
[TestRunnerThread] DEBUG NHibernate.Impl.SessionFactoryImpl - Session factory constructed with filter configurations : {}
[TestRunnerThread] DEBUG NHibernate.Impl.SessionFactoryImpl - instantiating session factory with properties: {'use_reflection_optimizer'='True', 'connection.provider'='NHibernate.Connection.DriverConnectionProvider', 'dialect'='NHibernate.Dialect.MsSql2008Dialect', 'connection.driver_class'='NHibernate.Driver.SqlClientDriver', 'connection.connection_string'='Server=MachineName\SQLEXPRESS;database=MySolution_Testing;Integrated Security=true;', 'proxyfactory.factory_class'='NHibernate.ByteCode.LinFu.ProxyFactoryFactory, Nhibernate.ByteCode.LinFu', 'show_sql'='true'}
[TestRunnerThread] DEBUG NHibernate.Connection.DriverConnectionProvider - Obtaining IDbConnection from Driver
[TestRunnerThread] DEBUG NHibernate.Connection.ConnectionProvider - Closing connection
As you can see, NHibernate seems to configure it self correctly, however, the final two lines seem to suggest that when a connection is actually asked for, something errors and it is all closed off. This is not reported back to NUnit and so it just sits there waiting indefinitely for a valid connection to use.
I have other projects that use a Fluent configuration that seem to function correctly, but these older projects use a SQL Compact database not SQL Express.
Is anyone able to suggest a solution to this issue ?
Thank you for your time.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
最可能的原因是堆栈溢出导致 nunit-agent.exe 进程崩溃。这会导致 nunit.exe 测试运行程序失去与代理进程的连接。有关详细信息,请参阅 NUnit 与 NHibernate 崩溃。
我知道这已经快一年了,但希望您或其他人可能会发现它有用。
The most likely cause of this is a stack overflow that crashes the nunit-agent.exe process. This causes the nunit.exe test runner to lose its connection to the agent process. See NUnit crashing with NHibernate for more information.
I know this is almost a year old but hopefully you or someone else may find this to be of use.