The application will use sdf files that the user can switch so all the
configuration is done through code. This code is included in
DatabaseServer.dll:
Configuration cfg = new Configuration();
cfg.Properties["connection.provider"] =
"NHibernate.Connection.DriverConnectionProvider";
cfg.Properties["dialect"] = "NHibernate.Dialect.MsSqlCeDialect";
cfg.Properties["hibernate.connection.driver_class"] =
"NHibernate.Driver.SqlServerCeDriver";
cfg.Properties["hibernate.connection.connection_string"] =
path;
cfg.AddAssembly(this.GetType().Assembly);
cfg.AddXmlFile("Mappings\\Project.hbm.xml"); ->> ERROR HERE
sessionFactory = cfg.BuildSessionFactory();
An error is thrown when the code is adding the hbm file:
NHibernate.MappingException: Could not configure datastore from file
Mappings\Project.hbm.xml ---> System.IO.DirectoryNotFoundException:
Could not find a part of the path 'D:\Documents\my documents\Visual
Studio 2010\Projects\Application\GUI\bin\Debug\Mappings
\Project.hbm.xml'.
Looking in the debug folder under the GUI project, I can see that
there is no Mapping folder in it. Why is NHIbernate looking for it.
Its supposed to be embedded in the DatabaseServer.dll.
Thanks,
Yoav
The problem is that you are telling NHibernate to load
Mappings\Project.hbm.xml as an external file, but it's stored as an embedded
resource in the DLL or EXE. The solution is to remove the statement
cfg.AddXmlFile(...); and instead let NHibernate find the mapping files as
embedded resources in the appropriate assembly; e.g.
cfg.AddAssembly(... appropriate assembly reference ...);
sessionFactory = cfg.BuildSessionFactory();
Note that the assembly referenced should be the assembly containing the
mapping file and the embedded resources should all have an .hbm.xml
extension.
--
You received this message because you are subscribed to the Google Groups
"nhusers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/nhusers?hl=en.