Thanks Jason.
I'm using Ninject as IoC container. But I can't figure out how to configure
it in such a hybrid scenario.
I know it is not that easy to explain with so little information. But even
just a link would help.
Thanks,
Marcello.
Il giorno mercoledì 28 novembre 2012 12:21:43 UTC+1, Jason Meckley ha
scritto:
>
> 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/-/j6Pmm0w8a40J.
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.