Update,

I'm not sure where I got the NHibernate.3.4.0-Alpha1-nuget-package from,
can't find it today when trying to set everything up again so was
recreating everything with the NHibernate.3.3.3-CR1
and NHibernate.3.3.2.4000 package with the same result as previous.

Also tested with static ICurrentSessionContext-implementation also with the
same exception.

// Patric

On 15 March 2013 23:22, Patric Forsgard <[email protected]> wrote:

> Hi.
>
> When trying to complete a TransactionScope I got
> "System.InvalidOperationException: The operation is not valid for the
> current state of the enlistment." with the following stacktrace.
>
> [InvalidOperationException: The operation is not valid for the current state 
> of the enlistment.]
>    System.Transactions.EnlistmentState.InternalIndoubt(InternalEnlistment 
> enlistment) +47
>    
> System.Transactions.VolatileDemultiplexer.BroadcastInDoubt(VolatileEnlistmentSet&
>  volatiles) +53
>    
> System.Transactions.TransactionStatePromotedIndoubt.EnterState(InternalTransaction
>  tx) +89
>    System.Transactions.SinglePhaseEnlistment.InDoubt(Exception e) +358
>    
> System.Data.SqlClient.SqlDelegatedTransaction.SinglePhaseCommit(SinglePhaseEnlistment
>  enlistment) +646
>    
> System.Transactions.TransactionStateDelegatedCommitting.EnterState(InternalTransaction
>  tx) +359
>    System.Transactions.CommittableTransaction.Commit() +398
>    System.Transactions.TransactionScope.InternalDispose() +638
>    System.Transactions.TransactionScope.Dispose() +2492
>    ASP.testfiles_sessiontest_aspx.Page_Load(Object sender, EventArgs e) in 
> c:\Project\Litium.Studio\TestBranches\Dev-NH\Src\Web\TestFiles\SessionTest.aspx:28
>    System.Web.UI.Control.LoadRecursive() +71
>    System.Web.UI.Page.ProcessRequestMain(Boolean 
> includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3178
>
>
> Direct after the first exception my
> AppDomain.CurrentDomain.UnhandledException-handler is registering this
> exception before the IIS application is crashing.
>
> ------------------------------
> UnhandledException:
>
> appId=/LM/W3SVC/21/ROOT
>
> type=System.InvalidOperationException
>
> message=The operation is not valid for the current state of the enlistment.
>
> stack=
>    at System.Transactions.EnlistmentState.ForceRollback(InternalEnlistment
> enlistment, Exception e)
>    at System.Transactions.PreparingEnlistment.ForceRollback(Exception e)
>    at
> NHibernate.Transaction.AdoNetWithDistributedTransactionFactory.DistributedTransactionContext.System.Transactions.IEnlistmentNotification.Prepare(PreparingEnlistment
> preparingEnlistment)
>    at
> System.Transactions.VolatileEnlistmentPreparing.EnterState(InternalEnlistment
> enlistment)
>    at
> System.Transactions.TransactionStatePromotedPhase0.EnterState(InternalTransaction
> tx)
>    at System.Transactions.Phase0VolatileDemultiplexer.InternalPrepare()
>    at System.Transactions.VolatileDemultiplexer.PoolablePrepare(Object
> state)
>    at
> System.Transactions.Oletx.OletxVolatileEnlistment.Prepare(OletxVolatileEnlistmentContainer
> container)
>    at
> System.Transactions.Oletx.OletxPhase0VolatileEnlistmentContainer.Phase0Request(Boolean
> abortHint)
>    at
> System.Transactions.Oletx.OletxTransactionManager.ShimNotificationCallback(Object
> state, Boolean timeout)
>    at
> System.Threading._ThreadPoolWaitOrTimerCallback.PerformWaitOrTimerCallback(Object
> state, Boolean timedOut)
> ------------------------------
>
> NHibernate log
> ------------------------------
> 2013-03-15 23:20:00,676 [     ] DEBUG NHibernate.Impl.SessionImpl -
> [session-id=b44d75bc-4eb1-4a05-a8c8-728c6ec78396] opened session at
> timestamp: 634989864006, for session factory:
> [/57fa339189e0461b8925d0ca8ba5b0fa]
> 2013-03-15 23:20:00,682 [     ] DEBUG
> NHibernate.Transaction.ITransactionFactory - enlisted into DTC transaction:
> Serializable
> 2013-03-15 23:20:00,691 [     ] DEBUG
> NHibernate.Transaction.AdoTransaction - Begin (Unspecified)
> 2013-03-15 23:20:00,692 [     ] DEBUG
> NHibernate.Connection.DriverConnectionProvider - Obtaining IDbConnection
> from Driver
> 2013-03-15 23:20:00,701 [     ] DEBUG
> NHibernate.Transaction.AdoTransaction - Start Commit
> 2013-03-15 23:20:01,730 [     ] DEBUG NHibernate.Impl.SessionImpl - before
> transaction completion
> 2013-03-15 23:20:01,734 [     ] DEBUG
> NHibernate.Transaction.AdoTransaction - IDbTransaction Committed
> 2013-03-15 23:20:01,740 [     ] DEBUG NHibernate.Impl.SessionImpl -
> transaction completion
> 2013-03-15 23:20:01,742 [     ] DEBUG NHibernate.AdoNet.ConnectionManager
> - aggressively releasing database connection
> 2013-03-15 23:20:01,743 [     ] DEBUG
> NHibernate.Connection.ConnectionProvider - Closing connection
> 2013-03-15 23:20:01,756 [     ] DEBUG
> NHibernate.Transaction.AdoTransaction - IDbTransaction disposed.
> 2013-03-15 23:20:01,764 [     ] DEBUG NHibernate.Impl.SessionImpl - before
> transaction completion
> 2013-03-15 23:20:21,764 [     ] DEBUG
> NHibernate.Transaction.ITransactionFactory -
> [session-id=b44d75bc-4eb1-4a05-a8c8-728c6ec78396] Flushing from Dtc
> Transaction
> 2013-03-15 23:20:21,766 [     ] DEBUG
> NHibernate.Transaction.ITransactionFactory - prepared for DTC transaction
> 2013-03-15 23:20:21,769 [     ] ERROR
> NHibernate.Transaction.ITransactionFactory - DTC transaction prepre phase
> failed
> ------------------------------
>
>
> File: SessionTest.aspx
> ------------------------------
> <%@ Page Language="C#" %>
> <%@ Import Namespace="System.Transactions" %>
> <%@ Import Namespace="NHibernate" %>
>
> <script runat="server">
> protected void Page_Load(object sender, EventArgs e)
>  {
> var sessionFactory = IoC.Resolve<ISessionFactory>(); // Wrapper around
> Windsor-container
>  using (var scope = new TransactionScope())
> {
> var session = sessionFactory.OpenSession();
>  {
> using (var tran = session.BeginTransaction())
> {
>  session.Flush();
> tran.Commit();
> }
>  }
> scope.Complete();
> }
>  }
>
> </script>
> OK
> ------------------------------
>
> The code is working correctly when running from xUnit-test without
> exception but not when running inside IIS on Windows 7 x64, database is SQL
> Server 2012 and .net framework 4.5. The code is also working if I remove
> the TransactionScope or not run the scope.Complete() to rollback the
> transaction.
>
> Have tried with ICurrentSessionContext that handle sessions both in the
> HttpContext.Current.Items and
> in System.Runtime.Remoting.Messaging.CallContext with the same exception
> (will try with static session handling but don't think that matter in this
> case).
>
> I'm using the NHibernate.3.4.0-Alpha1 nuget package of NHibernate, know
> that it is a prerelease and have not tested with latest stable/dev-version
> but will do that if not anyone will have any good suggestions what it can
> be.
>
> Anyone that have a suggestion what it can be or if it already exists any
> open bugs regarding the same exception? Tried to find in jira and find some
> with the same exception but with different messages and stacktrace.
>
> // Patric
>
>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"nhibernate-development" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to