I am having trouble with NHibernate sessions and threads. I have a class that creates a new thread which polls a database every 5 seconds. The problem I'm having is that when the thread calls the code to open a new session. I get the following error:
Could not load file or assembly 'log4net, Version=1.2.9.0, Culture=neutral, PublicKeyToken=b32731d11ce58905' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)":"log4net, Version=1.2.9.0, Culture=neutral, PublicKeyToken=b32731d11ce58905"
If i don't use threads the code works fine but as soon as I try to use a seperate thread I get this error. I have log4net referenced etc. Here is the code I'm using to initialize my session factory etc:
Code:
public sealed class NHibernateHelper
{
private static readonly ISessionFactory sessionFactory;
static NHibernateHelper()
{
sessionFactory = new Configuration().Configure().BuildSessionFactory();
}
public static ISession GetNewSession()
{
return sessionFactory.OpenSession();
}
public static ISessionFactory SessionFactory()
{
return sessionFactory;
}
}
[/b]