【发布时间】:2019-07-10 22:18:31
【问题描述】:
我正在使用 nHibernate。
我制作了一个程序集(例如:DAL.dll),其中包含映射文件(.hbm.xml)和实体(.cs)。这个程序集有一个强名称(签名)。
我创建了一个控制台项目,它引用了 DAL 程序集 (DAL.dll)。
当我尝试实例化配置时,加载我的 DAL 程序集时失败。
错误如下:
NHibernate.MappingException:无法编译映射文档:DAL.Mappings.Cat.hbm.xml NHibernate.MappingException:持久类 DAL.Cat,未找到 DAL
这是控制台应用程序代码:
Configuration cfg = new Configuration();
cfg.SetProperty(Environment.ConnectionDriver, "NHibernate.Driver.SqlClientDriver");
cfg.SetProperty(Environment.ConnectionString, dsn);
cfg.SetProperty(Environment.Dialect, typeof(MsSql2005Dialect).AssemblyQualifiedName);
cfg.SetProperty(Environment.ProxyFactoryFactoryClass, typeof(NHibernate.ByteCode.Castle.ProxyFactoryFactory).AssemblyQualifiedName);
cfg.SetProperty(Environment.ShowSql, "true");
cfg.SetProperty(Environment.ConnectionProvider, typeof(DriverConnectionProvider).AssemblyQualifiedName);
cfg.AddAssembly(typeof(DAL).Assembly);
问题在于 hbm.xml 文件引用了这样的实体:
<class name="DAL.Cat,DAL">
除了使用全名(使用密钥等)引用每个类之外,还有其他解决方案吗
谢谢!
【问题讨论】:
标签: nhibernate assemblies