-->
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.  [ 6 posts ] 
Author Message
 Post subject: WinForms Designer and Hibernate Configuration Error
PostPosted: Sat Nov 12, 2005 10:41 pm 
Newbie

Joined: Sat Nov 12, 2005 10:27 pm
Posts: 1
Location: Boston, United States
Greetings,
I have a windows forms application that uses hibernate. The application is structured in a layered way UI / Business Logic / Data Access Layer each mapping to an assembly. The objects mapped to by hibernate are in a separate assembly as well (common data objects).

The UI assembly doesn't have any references to hibernate objects (i.e. session, factory, etc.) all of these are in the business logic assembly. There is an app.config file in the UI assembly with all the hibernate configurations and the assembly has references to the business logic assembly and the common data objects assembly.

The problem is that after I added a reference to the Business Logic assembly (which has hibernate references) and added a reference to NHibernate in the UI (for the config to load properly), I can no longer edit my main form in the designer.

When I open the main form, all my user controls get removed from the designer and I get the following errors:

An exception occurred while trying to create an instance of TestUserControl The exception was "The dialect was not set. Set the property hibernate.dialect.".

If I try to add an instance of any user control from my UI to the main form, I get the same exception and the control is not added.

Do I need to set any configurations manually for the designer to work properly?

If i don't open the form in the designer; the application works fine and no exceptions are thrown.

Thanks
Mario


Top
 Profile  
 
 Post subject:
PostPosted: Sun Nov 13, 2005 12:48 pm 
Contributor
Contributor

Joined: Thu May 12, 2005 9:45 am
Posts: 593
Location: nhibernate.org
It looks like the designer try to create a SessionFactory or something like that...

Check the constructor and the InitComp() methods to be sure that they don't contain NHibernate code.

Anyway, you shouldn't need to add a reference to NHibernate.dll in your WinApp. If you really want to separate them, but the NHibernate configuration in a "hibernate.cfg.xml" file...

_________________
Pierre Henri Kuaté.
Get NHibernate in Action Now!


Top
 Profile  
 
 Post subject:
PostPosted: Sun Nov 13, 2005 2:17 pm 
Thanks for the response KPixel.

I don't have any hibernate code in the constructor or initcomp; the UI doesn't have any hibernate code at all.

If i want to put all the configuration in an xml file along with the Business Logic layer where i think it should be. How do I load it when initializing the factory?

thanks
mario


Top
  
 
 Post subject:
PostPosted: Mon Nov 14, 2005 6:27 am 
Contributor
Contributor

Joined: Thu May 12, 2005 9:45 am
Posts: 593
Location: nhibernate.org
If the file is "hibernate.cfg.xml", call cfg.Configure();
else call cfg.Configure("file name here");

Tell me if you find out why your designer don't work.

_________________
Pierre Henri Kuaté.
Get NHibernate in Action Now!


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 16, 2005 8:53 pm 
Newbie

Joined: Thu Jun 09, 2005 12:48 pm
Posts: 5
Location: Portland, Oregon
Can I rename my app.config to hibernate.cfg.xml, move it to my bin/debug directory and it should work? I think that I may have to change the format?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 17, 2005 6:47 am 
Contributor
Contributor

Joined: Wed May 11, 2005 4:59 pm
Posts: 1766
Location: Prague, Czech Republic
Simply renaming it probably won't work, hibernate.cfg.xml has to have the right format (<hibernate-configuration> tag, right namespace, <session-factory> and <property> tags, etc.). But yes, if it's in bin/Debug folder NH should find it.


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