views:

49

answers:

0

I am using NHibernate in my web application. At one point it enters a loop (multiple threads may be looping) where it makes many calls to the database. It works fine for a while then will fail with the following error (when I call UnitOfWork.Start()):

No component for supporting the service Rhino.Commons.IUnitOfWorkFactory was found

Once I receive this error in a thread all subsequent calls to UnitOfWork.Start() (in that thread) fail for the same reason. Once the thread dies out the problem seems to dissapear as mysteriously as it arrived.

In looking through the Rhino.Commons code it looks like the Resolve method is failing. The component is registered in my application's Global.asax.cs file so I do not understand why Resolve will periodically fail. It's almost like my application loses the component registration for a brief period of time. What is causing this and what can I do to solve it?

Partial stack trace:

at Castle.MicroKernel.DefaultKernel.get_Item(Type service)
at Castle.Windsor.WindsorContainer.Resolve(Type service)
at Castle.Windsor.WindsorContainer.Resolve[T]()
at Rhino.Commons.IoC.Resolve[T]()
at Rhino.Commons.UnitOfWork.Start(IDbConnection connection, UnitOfWorkNestingOptions nestingOptions)

My application's Global.asax.cs :

public class Global: UnitOfWorkApplication
{
   protected override IWindsorContainer CreateContainer(string aWindsorConfig)
   {
      IWindsorContainer container = new WindsorContainer();
      container.Register(Component.For<IUnitOfWorkFactory>().ImplementedBy<NHibernateUnitOfWorkFactory>());
      return container;
   }
}