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.  [ 1 post ] 
Author Message
 Post subject: Configuration.AddAssembly won't load if dll not in app dir
PostPosted: Mon Nov 02, 2009 12:39 pm 
Newbie

Joined: Mon Nov 02, 2009 11:37 am
Posts: 1
Using NHibernate v2.0

I have been working on building a standalone schema generator. It accepts a path to your core assembly then generates the necessary sql create your schema in the db. I go to the path provided by the user and then load the assembly and pass it in to a call to NHibernate.cfg.Configuration.AddAssembly(assembly). However, when I do this, it fails, the exception says:

InnerException: System.IO.FileNotFoundException
Message="Could not load file or assembly NHibernateTest.Core' or one of its dependencies. The system cannot find the file specified."

I know AddAssembly is internally calling System.Reflection.Assembly.Load, but why can't it find the assembly if I've already called System.Reflection.Assembly.LoadFrom(path) and then passed the assembly to the call to AddAsssembly? The only resolution I have found is to go out to the path the user specified and move the dll into the schema generator's working directory. This seems like a bug.

To summarize, the following code fails if the dll for the assembly being passed in is not located in the app's working directory:

Code:
public static string Generate(Assembly assembly, string connectionString, string fileName, bool updateDatabase, bool reformat, bool exportToFile)
        {
            #region Configure NHibernate.
           
            NHibernate.Cfg.Configuration cfg = new NHibernate.Cfg.Configuration();
            cfg.AddAssembly(assembly);
         
          // Rest of method omitted

          }



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

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.