I have the following structure in Visual Studio
Control (Solution)
AppDB (Project)
Classes (Folder)
Piece.cs
Mapping (Folder)
PieceMap.cs
I add the assembly map at runtime doing the following instructions
Configuration hibernateConfiguration = new Configuration();
hibernateConfiguration.SetProperty("connection.connection_string", "server=(local);Data Source="+pRutaDB);
hibernateConfiguration.AddAssembly("AppDB.Mapping.PieceMap");
hibernateConfiguration = hibernateConfiguration.Configure();
NHibernate.ISessionFactory sessionFactory = hibernateConfiguration.BuildSessionFactory();
NHibernate.ISession session = sessionFactory.OpenSession();
NHibernate.ITransaction tr = session.BeginTransaction();
Piece p = new Piece();
p.name = "Test Piece";
pSession.SaveOrUpdate(p);
tr.Commit();
But when the tr.Commit() instruction arrives, thew following error shows up
Error: NHibernate.MappingException: Could not add assembly AppDb.Mapping.PieceMap ---> System.IO.FileNotFoundException
Anyone can tell me how to add the assembly at runtime?
Thanks!
Edit: with the instruction the error changed hibernateConfiguration.AddAssembly(typeof(GeometriaDB.Mapping.PieceMap).Assembly);
Now the following error appears:
NHibernate.MappingException: No persister for: GeometriaDB.Clases.Proyecto
So now why is that error appearing?