I am trying to configure nhibernate by loading the xml files from a assembly. My problem is that the assembly can not be found. If I deploy my application I have an application directory. Inside of the directory I have two other subdirectories called "Extensions" and "Plugins". The assembly I want to use is inside of the Extension directory, but the configuration will be called from the main application directory.
How do I set the directory where nhibernate can find the assembly with the mapping files? At the moment I have the following files and it does not work:
Code:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-configuration xmlns="urn:nhibernate-configuration-2.0" >
<session-factory name="NHibernate.JetDb">
<!-- properties -->
<!-- Connection provider -->
<property name="connection.provider">NHibernate.Connection.DriverConnectionProvider</property>
<!-- Driver -->
<property name="connection.driver_class">NHibernate.Driver.OleDbDriver</property>
<!-- Dialect -->
<property name="dialect">NHibernate.Dialect.MsSql2000Dialect</property>
<!-- Connection String -->
<property name="connection.connection_string">my connection string</property>
<!-- for debug purposes -->
<property name="show_sql">true</property>
<!-- Enables outer join fetching -->
<property name="use_outer_join">false</property>
<!-- Substitutions -->
<property name="query.substitutions">true 1, false 0, yes 'Y', no 'N'</property>
<!-- mapping files -->
<mapping resource="myNamespace.myClass.hbm.xml" assembly="MyAssembly.dll" />
</session-factory>
</hibernate-configuration>
And here is the mapping file:
Code:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0" namespace="myNamespace" assembly="myAssembly.dll" >
<class name="myClass" table="myTable">
<id name="Id" column="Id" type="System.Guid">
<generator class="guid" />
</id>
<!-- and the other columns -->
</class>
</hibernate-mapping>
What I get is the error message: "File Not Found: myAssembly.dll"
If I delete the mapping line from the cfg file and try to load it manually then I get an error: "Persistent class: MyClass not found."
I believe that these errors occure because the main application is started from the application directory and myAssembly.dll is located in the "Extensions" subdirectory.
Any solutions? Can I set the assembly path related to the main application directory somehow in these config files?