Nhibernate add GAC assembly to mapping-by-code

508 views Asked by At

I have EmployeeEntity stored in MyCompany.Entities.Employee.dll and EmployeeMap: ClassMapping<SPListItem> in MyCompany.Mapping.dll, both in GAC.

I use mapping-by-code to create ISessionFactory implementation like this:

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();

How should I properly configure Configuration instance to use GAC assemblies in my mapping?

2

There are 2 answers

0
dbardakov On BEST ANSWER

I found that there are solution

mapping.assembly = "MyCompany.Entities.Employee assembly strong name";

4
Ricardo Peres On

This has nothing to do with GAC. You need to catch the exception and look at the inner exception to find out what is wrong - probably something in the mapping.