I have an old MonoRail/ActiveRecord I've been doing some work too.
Recently I decided to upgrade the application to Castle Trunk & NHibernate 2.1.0.4000 GA and I'm now finding a few issues with running tests:
First off - When using TestDriven.Net to run the integration tests that work against the database, it's crashing TestDriven.Net altogether, or all the tests complete execution, then TestDriven.Net hangs. This never happened prior to the upgrade.
When TestDriven.Net crashes, here's what gets written to the event log:
Fault bucket 1467169527, type 1 Event Name: APPCRASH Response: Not available Cab Id: 0
Problem signature: P1: ProcessInvocation86.exe P2: 2.22.2468.0 P3: 4a26845c P4: KERNELBASE.dll P5: 6.1.7600.16385 P6: 4a5bdbdf P7: e053534f P8: 0000b727 P9: P10:
Second thing - Exceptions are being logged when proxy classes are being Finalize()'d, as below - it seems to be once this is logged a couple of times, that is when TestDriven.Net crashes.
Here's the stack trace for the exception:
NHibernate.LazyInitializationException:
Initializing[MyApp.Core.Models.TestExecutionPackage#15d9eb96-faf0-4b4b-9c5c-9cd400065430]-Could not initialize proxy - no Session.
at NHibernate.Proxy.AbstractLazyInitializer.Initialize()
at NHibernate.Proxy.AbstractLazyInitializer.GetImplementation()
at NHibernate.ByteCode.Castle.LazyInitializer.Intercept(IInvocation invocation)
at Castle.DynamicProxy.AbstractInvocation.Proceed()
at Castle.Proxies.TestExecutionPackageProxy.Finalize()
The same behaviour will also crash MsBuild on our CI Server.
What's really odd is that in theory exceptions thrown in Finalize() should be swallowed as per the MSDN docs:
http://msdn.microsoft.com/en-us/library/system.object.finalize%28VS.71%29.aspx
If Finalize or an override of Finalize throws an exception, the runtime ignores the exception, terminates that Finalize method, and continues the finalization process.
Thoughts anyone?