-->
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.  [ 5 posts ] 
Author Message
 Post subject: Where to store NHibernate config when exe isn't yours
PostPosted: Wed Nov 15, 2006 3:51 pm 
Expert
Expert

Joined: Fri Oct 28, 2005 5:38 pm
Posts: 390
Location: Cedarburg, WI
I've created some DLLs that use NHibernate, that get loaded and used by 3rd party applications. One of these applications is Visual Studio. What is the recommended way of telling NHibernate where to find the config info, particularly when you do not own the running application? Currently I'm putting config info into the 3rd party app's .exe.config, but that's just a temporary kludge.


Top
 Profile  
 
 Post subject: Re: Where to store NHibernate config when exe isn't yours
PostPosted: Wed Nov 15, 2006 4:00 pm 
Newbie

Joined: Sun Aug 28, 2005 10:54 pm
Posts: 14
Nels_P_Olsen wrote:
I've created some DLLs that use NHibernate, that get loaded and used by 3rd party applications. One of these applications is Visual Studio. What is the recommended way of telling NHibernate where to find the config info, particularly when you do not own the running application? Currently I'm putting config info into the 3rd party app's .exe.config, but that's just a temporary kludge.


In the .exe application configuration file, you could store the path to the session factory configuration file instead of all of the session factory configuration. There is an overload for the Configuration.Configure() method that takes a path to this file.

The format of the file is described in section 3.8 in the documentation: http://www.hibernate.org/hib_docs/nhibe ... ation.html.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 15, 2006 4:05 pm 
Expert
Expert

Joined: Fri Oct 28, 2005 5:38 pm
Posts: 390
Location: Cedarburg, WI
Hmmm... I'll look into that. Still, it doesn't totally avoid having to modify some other app's config file. We might not have permission to modify it at all ...


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 16, 2006 2:38 am 
Contributor
Contributor

Joined: Wed May 11, 2005 4:59 pm
Posts: 1766
Location: Prague, Czech Republic
You don't have to modify the app.config at all, what sguidi suggested was that app.config is a convenient way to store the path to the nhibernate.cfg.xml file. If you don't want to store it in the app.config, store it somewhere else, NHibernate doesn't care.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 16, 2006 12:16 pm 
Expert
Expert

Joined: Fri Oct 28, 2005 5:38 pm
Posts: 390
Location: Cedarburg, WI
Let me clarify the question. It's not a problem to come up with a functioning way to locate an Nhibernate.cfg.xml file without assuming it's in the running application's base directory -- the question is, what is a "good" or "recommended" way.

We could kludge something checking an environment variable, but that would be horribly lame and wouldn't support multiple installations of our DLL on the machine at one time. We could check some registry setting, but that means we have to set up a registry key during installation, which we don't want to do either. We could assume it's under Environment.SpecialFolder.CommonApplicationData under a folder with our product's name and version, that might not be so bad ...

Does anyone else have this issue? If so, how are you addressing it?


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