I think the important detail for the exception is:

2010-08-20 15:27:22,563 [6] ERROR NHibernate.Impl.AbstractSessionImpl
- DTC transaction prepre phase failed
System.Transactions.TransactionException: The operation is not valid
for the state of the transaction. --->
System.Data.SqlClient.SqlException: Timeout expired.  The timeout
period elapsed prior to completion of the operation or the server is
not responding.
   at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException
exception, Boolean breakConnection)
   at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning()
   at
System.Data.SqlClient.TdsParserStateObject.ReadSniError(TdsParserStateObject
stateObj, UInt32 error)
   at System.Data.SqlClient.TdsParserStateObject.ReadSni(DbAsyncResult
asyncResult, TdsParserStateObject stateObj)
   at System.Data.SqlClient.TdsParserStateObject.ReadNetworkPacket()
   at System.Data.SqlClient.TdsParserStateObject.ReadBuffer()
   at System.Data.SqlClient.TdsParserStateObject.ReadByte()
   at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior,
SqlCommand cmdHandler, SqlDataReader dataStream,
BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject
stateObj)
   at
System.Data.SqlClient.TdsParser.TdsExecuteTransactionManagerRequest(Byte[]
buffer, TransactionManagerRequestType request, String transactionName,
TransactionManagerIsolationLevel isoLevel, Int32 timeout,
SqlInternalTransaction transaction, TdsParserStateObject stateObj,
Boolean isDelegateControlRequest)
   at
System.Data.SqlClient.SqlInternalConnectionTds.ExecuteTransactionYukon(TransactionRequest
transactionRequest, String transactionName, IsolationLevel iso,
SqlInternalTransaction internalTransaction, Boolean
isDelegateControlRequest)
   at
System.Data.SqlClient.SqlInternalConnectionTds.ExecuteTransaction(TransactionRequest
transactionRequest, String name, IsolationLevel iso,
SqlInternalTransaction internalTransaction, Boolean
isDelegateControlRequest)
   at
System.Data.SqlClient.SqlDelegatedTransaction.SinglePhaseCommit(SinglePhaseEnlistment
enlistment)






On Aug 20, 3:38 pm, Ollie Riches <[email protected]> wrote:
> I'm receiving the following error when I started using MessageQueue
> inside a TransactionScope transaction - any ideas why this is
> happening, I realise the transaction is now getting prompted to a
> distributed transaction and hence have turned on and configured MSDTC.
>
> I suspect this is something to do with row count, does anyone know?
>
> Shown below is the MessageQueue that is causing NH to fail:
>
>                 using (var queue = new MessageQueue(_exportEndpoint))
>                 {
>                     var label = string.Format("{0} ComponentId - {1}",
> DateTime.Now.ToUniversalTime(), componentId);
>                     queue.Send(contents, label,
> MessageQueueTransactionType.Automatic);
>                     _log.WriteInfo("ExportToQueue: Message sent to
> queue - " + label);
>                 }
>
> Shown below is the exception from NH:
>
> 2010-08-20 15:27:22,516 [6] ERROR
> NHibernate.Event.Default.AbstractFlushingEventListener - Could not
> synchronize database state with session
> NHibernate.StaleStateException: Unexpected row count: -1; expected: 1
>    at
> NHibernate.AdoNet.Expectations.BasicExpectation.VerifyOutcomeNonBatched(Int32
> rowCount, IDbCommand statement)
>    at NHibernate.AdoNet.NonBatchingBatcher.AddToBatch(IExpectation
> expectation)
>    at
> NHibernate.Persister.Entity.AbstractEntityPersister.Update(Object id,
> Object[] fields, Object[] oldFields, Object rowId, Boolean[]
> includeProperty, Int32 j, Object oldVersion, Object obj,
> SqlCommandInfo sql, ISessionImplementor session)
>    at
> NHibernate.Persister.Entity.AbstractEntityPersister.UpdateOrInsert(Object
> id, Object[] fields, Object[] oldFields, Object rowId, Boolean[]
> includeProperty, Int32 j, Object oldVersion, Object obj,
> SqlCommandInfo sql, ISessionImplementor session)
>    at
> NHibernate.Persister.Entity.AbstractEntityPersister.Update(Object id,
> Object[] fields, Int32[] dirtyFields, Boolean hasDirtyCollection,
> Object[] oldFields, Object oldVersion, Object obj, Object rowId,
> ISessionImplementor session)
>    at NHibernate.Action.EntityUpdateAction.Execute()
>    at NHibernate.Engine.ActionQueue.Execute(IExecutable executable)
>    at NHibernate.Engine.ActionQueue.ExecuteActions(IList list)
>    at NHibernate.Engine.ActionQueue.ExecuteActions()
>    at
> NHibernate.Event.Default.AbstractFlushingEventListener.PerformExecutions(IEventSource
> session)

-- 
You received this message because you are subscribed to the Google Groups 
"nhusers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/nhusers?hl=en.

Reply via email to