我已将我的Fluent NHibenate升级到1.2,因为我已将NHibenate升级到3.0版.这反过来是因为我在我的项目中使用ANTLR并且在ANTLR版本之间存在兼容性问题.我现在得到这个错误创建映射作为Fluently.Configure()调用的一部分,我以前没有使用相同的程序集与版本1.0.XX.我在VS2008中使用C#.NET 3.5进行开发.
错误是"动态程序集中不支持调用的成员".
public static ISessionFactory GetFactory()
{
if (_factory == null)
{
Assembly assembly = Assembly.Load("BigFoot.Infrastructure");
IApplicationContext springContainer = ContextRegistry.GetContext();
IDbProvider provider = (IDbProvider)springContainer.GetObject("DbProvider");
string connection = provider.ConnectionString;
if (connection.Length > 0)
{
_factory = Fluently.Configure()
.Database(MsSqlConfiguration.MsSql2008.ConnectionString(connection))
.Mappings(m =>
{
m.FluentMappings.AddFromAssembly(assembly);
m.HbmMappings.AddFromAssembly(assembly);
})
.BuildSessionFactory();
}
}
return _factory;
}
Run Code Online (Sandbox Code Playgroud)