I have a WCF service using NHibernate, I am trying to connect this WCF service thru my WPF and get all the records from my SQL db. Some how it throws this exception and i don’t have no clue about this.Any please give me a hand to sort this issue.
Exception :
The type initializer for ‘Gateway.DataAccess.NHibernateDAO.NHibernateHelper’ threw an exception.
Resulting in:
An exception occurred while trying to create an instance of type ‘Client.Modules.Metadata.ViewModel.StoriesViewModel’.
This my NHibernateHelper class
namespace Webster.Gateway.DataAccess.NHibernateDAO
{
public sealed class NHibernateHelper
{
private const string CurrentSessionKey = "nhibernate.current_session";
// An ISessionFactory is threadsafe, many threads can access it concurrently and request ISessions
private static readonly ISessionFactory sessionFactory;
// An ISession is a non-threadsafe object that represents a single unit-of-work with the database
////private static ISession currentSession;
public static ISessionFactory SessionFactory
{
get
{
return sessionFactory;
}
}
static NHibernateHelper()
{
sessionFactory = new Configuration().Configure().BuildSessionFactory();
}
}
}
Found the culprit,its nothing to do with my app,all i have to change the Application Pool setting in IIS and the Identity to my user name.I was hosting this WCF service in IIS.
It works fine now thanks a lot guys .