-->
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: Running hbm2ddl
PostPosted: Sun Dec 21, 2008 6:01 pm 
Beginner
Beginner

Joined: Fri Jul 06, 2007 9:27 pm
Posts: 22
I'm learning NHibernate, and I am at the point where I can get a simple app up and running with NHibernate 1.2. Right now, I'm playing with SchemaExport, which I normally invoke from the unit test project in a VS 2008 solution.

I've created a simple GUI wrapper to run SchemaExport. The GUI references its own copy of NHibernate, and it uses the cfg.Configure() overload that lets me specify the config file to use:

Code:
// Create NHibernate SchemaExport object
Configuration cfg = new Configuration();
cfg.Configure(txtCfgFilePath.Text);
SchemaExport schema = new SchemaExport(cfg);


I am using as my target a project with a known working configuration file and mapping files. But when I invoke cfg.Configure() per above, I get this error from NHibernate:

Code:
Could not add assembly MyDemo


The InnerException reads:

Code:
Could not load file or assembly 'WpfNHibDemo' or one of its dependencies. The system cannot find the file specified.":"WpfNHibDemo"


In other words, NHibernate finds the assembly from the config file when I run MyDemo, but it doesn't find it if I use my GUI to load the config file.

While learning NHibernate, I've read that the config file must be in the project output folder of the application calling NHibernate--in this case my GUI. That would explain why NHibernate finds the assembly when I run MyDrmo but not the GUI.

Can anyone shed any light on this problem? How do I get around it? Thanks for your help.

David Veeneman
Foresight Systems


Top
 Profile  
 
 Post subject:
PostPosted: Tue Dec 23, 2008 6:58 pm 
Beginner
Beginner

Joined: Fri Jul 06, 2007 9:27 pm
Posts: 22
Answered my own question. The solution turnsout to be fairly simple, if one configures NHibernate from code, using the SetProperty() or SetProperties() methods. For my GUI, that turns out to be what I want to do anyway. The assembly with the mapping files is added to the configuration using the AddAssembly() method.

Once I have the GUI app working, I am planning to post it on CodeProject.com, so you might check there for the utility.


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.