I'm configuring NHibernate on SharePoint 2010 web application. Previously it works fine when mappings and domain were in one project. But during refactoring process I splitted solution on several projects. I've also implemented my custom IHttpModule where I want to initialize nhibernate configuration
protected void context_BeginRequest(object sender, EventArgs e)
{
var httpApplication = sender as HttpApplication;
lock (httpApplication )
{
if (!httpApplication.Context.Items.Contains(ApplicationConstants.IsApplicationInitialized))
{
httpApplication.Context.Items.Add(ApplicationConstants.IsApplicationInitialized, true);
InitInRequest(httpApplication);
}
}
httpApplication.Context.Items.Add(ApplicationConstants.SESSION, NhibernateManager.GetSession());
}
private void InitInRequest(HttpApplication httpApplication)
{
NhibernateManager.Init(ApplicationVariables.ApplicationSettingsPath);
}
And NHibernateManager.Init():
public static void Init(string configurationFilePath)
{
specifiedConfigurationFilePath = configurationFilePath;
Configure();
InitSessionFactory();
}
private static void Configure()
{
if (config == null)
{
if (string.IsNullOrEmpty(specifiedConfigurationFilePath) == false)
{
config = new Configuration();
config = config.Configure(specifiedConfigurationFilePath);
config = Fluently.Configure(config)
.Mappings(m => m.FluentMappings.AddFromAssemblyOf<ItemMap>())
.BuildConfiguration();
}
else
{
config = Fluently.Configure()
.Mappings(m => m.FluentMappings.AddFromAssemblyOf<ItemMap>())
.BuildConfiguration();
}
}
}
And in BuildConfiguration() I have very strange error (InnerException): "Entry point was not found." Stack trace shows that getting mapping information is cause of error:
at System.Collections.Generic.IDictionary`2.TryGetValue(TKey key, TValue& value)
at NHibernate.Cfg.Configuration.GetClassMapping(String entityName)
at NHibernate.Cfg.Configuration.GetClassMapping(Type persistentClass)
at FluentNHibernate.PersistenceModel.Configure(Configuration cfg)
at FluentNHibernate.Cfg.MappingConfiguration.Apply(Configuration cfg)
at FluentNHibernate.Cfg.FluentConfiguration.BuildConfiguration()
All assemblies are in the GAC. I tried to copy them in _app_bin or bin but without success.
UPDATE
Please, help me! I'm stuck with this weird problem :(