Hi,
I have a small problem. When I am running my application and I want to access the module ISessionManager I get the Visual Studio Just-In-Time Debugger with the following error:
An unhandled exception ('Castle.Microkernel.Facilities.FacilityException') ocurred in aspnet_wp.exe[4936]
When compiling with debugger mode, I get the following error:
FacilityException was unhandled WebSessionStore: Could not obtain reference to HttpContext
As explanatory note, I am working with execution threads.
Thanks
You have a problem here, because there is no HttpContext (used to store the Session) in separate threads.
As a workaround you could access the ISessionFactory directly and obtain a session from it. The ISessionFactory is stored in the container so you can get it via ContainerAccessorUtil.GetContainer().Resolve(typeof(ISessionFactory)).
In the next version, there is a static IoC helper class in the core that makes this also possible from projects that don't have a reference to the Cuyahoga.Web assembly.
Hope this helps.
Forgive Martin, but not finish understand the idea of obtaining the meeting.
I have been watching and call ContainerAccessorUtil.GetContainer().Resolve(typeof(ISessionFactory)) runs from HttpContext.Current which is precisely what I do not. He looked to send the thread as a parameter to pass the HttpContext.Current but loses the module's reference ApplicationInstance
May be more simple than it seems but can not find the way, forgive my ignorance.
Ah, I'm stupid! Of course, the ContainerAccessorUtil doesn't work without the HttpContext.
Check out the 1.5.x branch (
https://cuyahoga.svn.sourceforge.net/svnroot/cuyahoga/branches/1.5.x). There is an IoC helper class in /Core/Util that allows to resolve components outside the http context. Also, check out /Web/Global.asax.cs to see how this class is initialized. Finally, in /Cuyahoga.Modules.RemoteContent/RemoteContentModule.cs, you can find code that uses NHibernate in a separate thread.
Hi,
While typing in the forum and I commented I was looking for an alternative solution, send the information httpcontext the moment I think the thread, "fight" with the container to get the meeting and one of my many attempts found a solution, not whether it will be the most feasible at the moment but with a small line I had worked well.
ISession session = this.NHSession.SessionFactory.OpenSession ();
As solve some problems of mapping of the class that I review what has commented.
I hope that this small contribution serves, and if you have any suggestions accept it gladly.
Thanks