I am working on a small app to provide a GUI wrapper for SchemaExport. Here is the code I am using to configure NHibernate:
Code:
// Get assembly
Assembly assembly = Assembly.LoadFile(filePath);
// Configure NHibernate
Configuration configuration = new Configuration();
configuration.SetProperties(props);
configuration.AddAssembly(assembly);
Props is an IDictionary set up to work with SetProperties().
I am testing the app against a known working assembly, MyAssembly, that contains persistent classes and mapping files. MyAssembly maps without problem in the app I created it for.
Here's my problem: If I copy MyAssembly to the project output folder for my GUI wrapper app, NHibernate maps the classes in the assembly without problem. But if I move MyAssembly to any other location, AddAssembly() throws an error "Persistent class [ClassName, Assembly] not found."
I am passing the assembly as an object, rather than simply it's name. So I am puzzled by why it finds classes only if the assembly in located in the GUI wrapper's project output folder.
Can anyone shed any light on this? I can hack my way around the problem by copying the assembly, but that's got a really bad smell to it. Is there an optioal property I can set to eliminate the problem?
Thanks for your help.
David Veeneman
Foresight Systems