-->
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.  [ 3 posts ] 
Author Message
 Post subject: Dynamically loaded assemblies
PostPosted: Sat Jan 28, 2006 11:45 am 
Newbie

Joined: Sat Jan 28, 2006 11:35 am
Posts: 7
I'm in the middle of writing some tools that might come handy in the project I recently started on. We're going to use NHibernate ... However, I was trying to implement a little tool that allows me to point to an assembly, and to generate the ddl for the mappings embedded in it.

I create a Configuration object, load the assembly after the user selected it, and pass it on to the configuration object. However, I get an exception (FileNotFoundException), indicating that the assembly could not be loaded.

Elsewhere I found that this is because NHibernate is using Type.GetType(..), which does not work when the assembly was dynamically loaded.

Does somebody have a decent solution for this, that does not require NHibernate and other assemblies depending on it to be recompiled?

Tx[/url]


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jan 28, 2006 12:12 pm 
Contributor
Contributor

Joined: Wed May 11, 2005 4:59 pm
Posts: 1766
Location: Prague, Czech Republic
This should work better in the latest version (1.0.2), if it doesn't, please report more details - the code you try to execute, the exception you are getting, etc.


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jan 28, 2006 12:40 pm 
Newbie

Joined: Sat Jan 28, 2006 11:35 am
Posts: 7
sergey wrote:
This should work better in the latest version (1.0.2), if it doesn't, please report more details - the code you try to execute, the exception you are getting, etc.


Sergey,


Thanks for the quick reaction. I am using using 1.0.2 as we speak. I have included the source code in my solution, to find out what is going on. This information might help you further:

The exception I get is a FileNotFoundException, thrown in ReflectHelper - TypeFromAssembly. An attempt to load the type with Type.GetType() did not return a type, and the code tries to load the assembly with a call to LoadWithPartialName. It is in this call that the exception is thrown.

This is the code that I wrote myself:


Code:
/// <summary>
/// Constructor
/// </summary>
public Mapping2DDLHelper(string pathToAssembly, string connectionString, string databaseDialect)
{
   _assembly = Assembly.LoadFrom(pathToAssembly);
   _configuration.AddAssembly(_assembly);
}


The exception is thrown in the last line ...

Regards,

Serge


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.