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
}