You are right Fabio. I did remove NHibernate facility and IRepository
dependency, configured ISessionFactroy, instead of IRepository just
build query directrly in the code. Did not get any error. There is
problem in IRepository when used with the Castle NHibernate Facility
Session manager. But it does not error out consistently and but in
random when used with WCF and NService bus together. Thank you for
guideness.

But that arises another question, how it closes the session. May not
be right to ask in this forum? But any help would be appreciated.

This is how my IReposity Get implementation looks like

 [Transaction(TransactionMode.Requires)]
        public virtual T Get<T>(IQuery<T> query)
                {
            using (var session = _sessionManager.OpenSession(DbAlias))
            {
                return
query.BuildQuery(session).List<T>().FirstOrDefault();
            }
                }



On Sep 1, 11:26 am, Fabio Maulo <[email protected]> wrote:
> You are closing the session in some other place.
> You will easy found it if you will try to recreate the situation in a
> pure-NH-100% test without all your wrappers (_sessionManager, _repository).
>
>
>
>
>
> On Wed, Sep 1, 2010 at 2:22 PM, Amzath <[email protected]> wrote:
> > As handler does not use MSDTC, I have removed transaction scope from
> > the code. Now code looks like this but getting same exception. Please
> > help me on this I have this issue in for last 10 days and could not
> > figure out why.
>
> > (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();
> >                                        }
> >                                }
>
> > On Sep 1, 9:43 am, Amzath <[email protected]> wrote:
> > > That did not help. Any other way to figure out why is that occuring?
>
> > > On Aug 31, 5:09 pm, Fabio Maulo <[email protected]> wrote:
>
> > > > 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]­>
> > <nhusers%[email protected]<nhusers%252bunsubscr...@googlegroup­s.com>
> > ­­>
> > > > > .
> > > > > For more options, visit this group at
> > > > >http://groups.google.com/group/nhusers?hl=en.
>
> > > > --
> > > > Fabio Maulo- Hide quoted text -
>
> > > > - Show quoted text -- Hide quoted text -
>
> > > - Show quoted text -
>
> > --
> > 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- Hide quoted text -
>
> - Show quoted text -

-- 
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