-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Dynamically loaded Assembly, cannot find class within
PostPosted: Sat Aug 04, 2007 10:52 am 
Newbie

Joined: Sat Aug 04, 2007 10:46 am
Posts: 8
*Searched forums a bit on this already*

Hi,
Using NHibernate 1.2. I need to add an assembly with mapping files from a subdirectory of my .exe, not the same directory. I can load the assembly fine doing this:

Code:
            string exeName = Application.ExecutablePath;
            string folder = Path.Combine(Path.GetDirectoryName(exeName), "SubFusion\\Plugins");
            Assembly assembly = Assembly.LoadFrom(folder + "\\" + name+".dll");
           
            config.AddAssembly(assembly);


but NHibernate cannot seem to find the classes referenced in the mapping file here (which is in the assembly).

Code:
<?xml version="1.0"?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2">
   <class name="FusionPlugin.Model.ConversationNode, FusionPlugin" table="fusion_quests_conv">
      <id name="Guid" type="string">
         <column name="guid" sql-type="varchar(64)" not-null="true" />
         <generator class="Fusion.FusionIDGenerator, SubFusion" />
      </id>
      <version name="version" access="field" column="version" type="timestamp" generated="always"/>
   </class>
</hibernate-mapping>


It complains with this:
{"persistent class FusionPlugin.Model.ConversationNode, FusionPlugin not found"}

which is weird since I could successfully load the assembly.

Now, it works fine, if the FusionPlugin assembly is in the same directory as the .exe, but since I can load it from the subdirectory, why can't NHibernate find the classes in it already?

I need to have it work from the subdirectory "SubFusion\\Plugins", not the .exe directory.

thank you for tips!
S


Top
 Profile  
 
 Post subject:
PostPosted: Sat Aug 04, 2007 12:53 pm 
Newbie

Joined: Sat Aug 04, 2007 10:46 am
Posts: 8
For future googlers, here is the solution I found.

You need to augment the binpath of the appdomain so NHibernate can resolve the types INSIDE the assembly.

For example:

string exeName = Application.ExecutablePath;
string folder = Path.Combine(Path.GetDirectoryName(exeName), "SubFusion\\Plugins");


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.