Nhibernate将GAC程序集添加到代码映射中

时间:2013-09-03 13:45:21

标签: nhibernate mapping-by-code

我在EmployeeEntityMyCompany.Entities.Employee.dll EmployeeMap: ClassMapping<SPListItem>存储了MyCompany.Mapping.dll,两者都存储在GAC中。

我使用map-by-code创建ISessionFactory实现,如下所示:

var config = new Configuration();
// Initialize config code omitted... 
var mapper = new ModelMapper();
mapper.AddMapping(typeof(EmployeeMap));   
config.AddDeserializedMapping(mapping, "ExampleMapping");
// Exception thrown here:Could not compile the mapping document: ExampleMapping
// InnerException:persistent class KT.NHibernate.Mapping.Entities.Employee, KT.Nhibernate.Mapping.Entities not found
return config.BuildSessionFactory();

如何正确配置Configuration实例以在映射中使用GAC程序集?

2 个答案:

答案 0 :(得分:0)

这与GAC无关。您需要捕获异常并查看内部异常以找出错误 - 可能是映射中的内容。

答案 1 :(得分:0)

我发现there are solution

  

mapping.assembly =“MyCompany.Entities.Employee程序集强名称”;