Hi,

If somebody is interested. I moved to Dynamic Proxy 2 and the problem
disappeared.
Apparently it is a bug in Castle Dynamic Proxy 1.

On Fri, Oct 16, 2009 at 10:26 AM, Humberto Marchezi <[email protected]>wrote:

> Hi,
>
> I use Castle Dynamic Proxy to insert aspects in the system we are doing
> here so that
> we don´t have to repeat the exception and session management code block all
> over the system.
>
> However the managed session is replaced with null value when the actual
> method gets called.
> See the code listing below in my dynamic proxy interceptor.
>
> Is there any restriction in using Castle Dynamic Proxy together with
> NHibernate ?
>
> *Interceptor:*
>
>     public class SessionTransactionExceptionAspect : IInterceptor
>     {
>         public void Intercept(IInvocation invocation)
>         {
>             NHibernate.ITransaction tx = null;
>             NHibernate.ISession s = null;
>             try
>             {
>                 s = NHDAOFactory.SessionFactory.OpenSession();
>                 CallSessionContext.Bind(s);
>                 tx =
> NHDAOFactory.SessionFactory.GetCurrentSession().BeginTransaction();
>                 retorno = invocation.Proceed();*<**- When it gets called
> then session (s) = NULL*
>                 tx.Commit();
>             }
>             catch (Exception exception)
>             {
>                 if (tx != null) { tx.Rollback(); }
>                 throw exception;
>             }
>             finally
>             {
>                 if (s != null) s.Close();
>                 CallSessionContext.Unbind(s.SessionFactory);
>             }
>         }
>     }
>
> Any ideas ?
>
> --
> Humberto C Marchezi
> ---------------------------------------------------------
> Master in Electrical Engineering - Automation
> Software Consultant and Developer
> at the Town Hall of Vitória
>



-- 
Humberto C Marchezi
---------------------------------------------------------
Master in Electrical Engineering - Automation
Software Consultant and Developer
at the Town Hall of Vitória

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