This thread looks to be a little on the old side and therefore may no longer be relevant. Please see if there is a newer thread on the subject and ensure you're using the most recent build of any software if your question regards a particular product.
This thread has been locked and is no longer accepting new posts, if you have a question regarding this topic please email us at support@mindscape.co.nz
|
Some unit tests, the ones with multieple unit of works I think, throw this error when the test's TransactionScope is disposed: TearDown : System.Reflection.TargetInvocationException : Exception has been thrown by the target of an invocation. ----> System.ObjectDisposedException : Cannot access a disposed object. Object name: 'Transaction'.--TearDown at System.RuntimeMethodHandle._InvokeMethodFast(Object target, Object[] arguments, SignatureStruct& sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner) at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks) at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) at NUnit.Core.TestMethod.doTearDown(TestCaseResult testResult) --ObjectDisposedException at System.Transactions.Transaction.get_TransactionInformation() at Mindscape.LightSpeed.UnitOfWork.?(Object , TransactionEventArgs ) at System.Transactions.TransactionCompletedEventHandler.Invoke(Object sender, TransactionEventArgs e) at System.Transactions.TransactionStatePromotedAborted.EnterState(InternalTransaction tx) at System.Transactions.SinglePhaseEnlistment.Aborted() at System.Data.SqlClient.SqlDelegatedTransaction.Rollback(SinglePhaseEnlistment enlistment) at System.Transactions.TransactionStateDelegatedAborting.EnterState(InternalTransaction tx) at System.Transactions.Transaction.Rollback() at System.Transactions.TransactionScope.InternalDispose() at System.Transactions.TransactionScope.Dispose() at Using LightSpeed 2.2.1572.14014. |
|
|
Bug in the .NET Framework: http://connect.microsoft.com/VisualStudio/feedback/details/294197/getting-a-objectdisposedexception-in-a-transactioncompleted-when-transactionscope-ends |
|
|
Fantastic. What is a way to fix this? (note that I have two unit of works because one logs error data that I always want saved) I had already looked at what LightSpeed was doing in Reflector and I came across this similar looking code from NHibernate which appears to deal with the error. What about doing something similar in LightSpeed? bool wasSuccessful = false; |
|
|
No, we can't do this in general for integrity reasons. Instead, as of LightSpeed 3 we simply skip the check unless we have stuff to do that depends on the transaction result. This solves the problem unless you are using full-text search or L2 caching. I am backporting the LightSpeed 3 code to 2.x and it should be in tonight's nightly build. |
|
|
Works for me. Thanks. |
|