我已将 Fluent NHibenate 升级到 1.2,因为我已将 NHibenate 升级到 3.0 版。这反过来是因为我在我的项目中使用了 ANTLR,并且在 ANTLR 版本之间存在兼容性问题。我现在在创建映射时遇到这个错误,作为 Fluently.Configure() 调用的一部分,我以前使用相同的程序集在 1.0.X.X 版中没有得到这个错误。我正在 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;
}
最佳答案
对于那些将再次面临问题的人。此异常是一种正常行为,因为它不是未处理的异常。您看到它的唯一原因是配置了 Visual Studio,因此您可以看到所有异常(已处理和未处理)并且“仅调试我的代码”被禁用。因此,您可以忽略异常并在捕获异常时按继续或配置 Visual Studio,以便它不会向您显示此类异常。
关于nhibernate - Fluent NHibernate 1.2 - 动态程序集中不支持被调用的成员,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5004270/