If you are not using MSDTC, like you mentioned earlier, you should not use TransactionScope. In your case the var tx is entirely unnecessary.
John Davidson On Tue, Aug 31, 2010 at 6:15 PM, Amzath <[email protected]> wrote: > Getting an error when commiting the transaction. I am opening and > closing the session properly. But I dont know why this error occurs? > Can any one helps me? > > Code: > > using (var tx = new TransactionScope(TransactionScopeOption.Suppress)) > using (var session = > _sessionManager.OpenSession(NetQuoteDatabase.Business)) > { > using (var tran = > session.BeginTransaction()) > { > > var Customer = > _repository.Get(new > CustomerByCustomerId(CustomerUpdate.CustomerIdentifier)); > > UpdateCustomerInfo(Customer, > CustomerUpdate); > > > UpdateCustomerAccountLimit(Customer, CustomerUpdate); > > > UpdateCustomerMethods(Customer, CustomerUpdate); > > _repository.Store(Customer); > > tran.Commit(); > } > tx.Complete(); > } > > Error: > > 2010-08-31 16:01:41,687 [Worker.5] ERROR > MyTest.ConsumerApp.Services.Handlers.CustomerUpdater [(null)] - End: > HandlingMessage: Failed handling CustomerUpdate message from > System.ObjectDisposedException: Cannot access a disposed object. > Object name: 'AdoTransaction'. > at NHibernate.Transaction.AdoTransaction.CheckNotDisposed() > at NHibernate.Transaction.AdoTransaction.Commit() > at > MyTest.ConsumerApp.Services.Handlers.CustomerUpdater.Handle(CustomerUpdate > CustomerUpdate) in C:\MyTest\trunk\ConsumerApp\Services\Handlers > \CustomerUpdater.cs:line 113 > > > -- > 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]<nhusers%[email protected]> > . > For more options, visit this group at > http://groups.google.com/group/nhusers?hl=en. > > -- 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.
