if you are using the "web" session context, but you are trying to bind the 
NH session outside of an HTTP request (which you are in a multi-threaded 
scenario) it will throw a NRE because there is no HTTP context to store the 
session (HttpContext.Current.Items[key] = session). Not sure if one exists, 
but you would want to use a hybrid context. or use an IoC container to 
manage the scope of the session rather than the SessoinFactory.

On Wednesday, November 28, 2012 5:57:19 AM UTC-5, Marcello Esposito wrote:
>
> Hi all.
>
> I have a ASP.NET MVC3 application using the Transaction ASP.NET MVC 
> action filter from NH 3 Cookbook, so current_session_context_class="web".
> Everything works fine except in a controller action method which uses 
> multi-threading.
> I cannot figure out how to initialize current session context used by 
> injected repositories (used within the threads).
>
> Each thread has the SessionFactory singleton injected and executes:
>
> using (var session = sessionFactory.OpenSession())
> {
>     CurrentSessionContext.Bind(session); <--- this throws 
> NullReferenceException
>
> Any help?
>
> Thanks in advance,
> Marcello.
>

-- 
You received this message because you are subscribed to the Google Groups 
"nhusers" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/nhusers/-/rbQWv_DCS6sJ.
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