0

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?

dbardakov
  • 651
  • 1
  • 8
  • 22

2 Answers2

0

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.

Ricardo Peres
  • 13,724
  • 5
  • 57
  • 74
  • `persistent class KT.NHibernate.Mapping.Entities.Employee, KT.Nhibernate.Mapping.Entities not found` – dbardakov Sep 03 '13 at 13:56
  • Are all classes public and in either a locally deployed assembly or in the GAC? You can also specify the full assembly qualified name including the public key token: KT.NHibernate.Mapping.Entities.Employee, KT.Nhibernate.Mapping.Entities, Version=xxx, Culture=neutral, PublicKeyToken=xxx. – Ricardo Peres Sep 03 '13 at 13:58
  • All classes are public, assemblies loaded into GAC (testsed with gacutil). Presented code run from ConsoleApplication. Specify full assembly name how? I tried `config.AddAssembly("MyCompany.Entities, Version=1.0.0.0, Culture=neutral, PublicKeyToken=0e3d5f149e92470e");` but still get same exception – dbardakov Sep 03 '13 at 14:23
  • OK, and do you have something like this on your .hbm.xml files: – Ricardo Peres Sep 03 '13 at 14:33
0

I found that there are solution

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

dbardakov
  • 651
  • 1
  • 8
  • 22