Put tx.Complete() in the 'using' of the TxScope not in the 'using' of the session.
On Tue, Aug 31, 2010 at 7:36 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(DatabaseAli)) > { > 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. > > -- Fabio Maulo -- 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.
