Hibernate version: NHibernate-1.2.0.CR2
Name and version of the database you are using:MsSql2005
Hi all,
I have a program that creates hbm.xml-files and the cfg.xml-file from a given assembly: It reads the assembly, and creates mappingfiles for the classes in the assembly.
That all works. Now I want to update the database with schemaexport. This is where it goes wrong. The assembly cannot be found.
Here is my code:
Code:
Configuration cfg = new Configuration();
//add the configfile as a stream
cfg.Configure(new XmlTextReader(GenerateConfiguration(false)));
//For testing I add only one file
string directoryMappings = "..\..\..\ConsoleApplication1\NHibernate";
string pathMappingFile = Path.Combine(directoryMappings, "Person.hbm.xml");
cfg.AddFile(pathMappingFile);
SchemaExport schemaExport = new SchemaExport(cfg);
schemaExport.Create(true, false);
The configuration works, but an error is generated when I try to add the file.
The file is found, the error is as shown below:
Code:
Could not compile the mapping document: ..\..\..\ConsoleApplication1\NHibernate\Person.hbm.xml
with the Exception
at NHibernate.Cfg.Configuration.LogAndThrow(MappingException me)
at NHibernate.Cfg.Configuration.AddValidatedDocument(XmlDocument doc, String name)
at NHibernate.Cfg.Configuration.AddXmlReader(XmlTextReader hbmReader, String name)
at NHibernate.Cfg.Configuration.AddXmlFile(String xmlFile)
at NHibernate.Cfg.Configuration.AddFile(String xmlFile)
at TestClass.OutputGenerator.GenerateDatabase()
The Exception has the following InnerExceptions:
-persistent class Debugging.Pimspace.Person, ConsoleApplication1 not found
-Could not load file or assembly 'ConsoleApplication1' or one of its dependencies. The system cannot locate the given path.
I think because that I use an external assembly, the system cannot locate the assembly, and throws the exception. Is there any way I can add the assembly to the configuration, so it will know that it must look in that assembly?
Thanks in advance,
Pim