Using application settings instead of config file

Posts   
 
    
mihies avatar
mihies
User
Posts: 800
Joined: 29-Jan-2006
# Posted on: 11-Jul-2006 14:37:35   

Suggestion: If you use application settings (.net 2 thing) then you don't need to copy config file to exe project (as opposed to classic .config file where library config files are ignored).

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 11-Jul-2006 15:00:16   

I don't get it?

Are you saying there will be no need for a config file or ini file at least? How the configuration settings should be changed (configured at runtime)? If a file won't be used?

mihies avatar
mihies
User
Posts: 800
Joined: 29-Jan-2006
# Posted on: 11-Jul-2006 22:16:43   

Walaa wrote:

I don't get it?

Are you saying there will be no need for a config file or ini file at least? How the configuration settings should be changed (configured at runtime)? If a file won't be used?

I'll illustrate. You generate the code. The database specific project (I am talking about adapter scenario) has an app.config file which holds default connection string. To use this connection string you have to copy the app.config into exe's app.config file (or web.config). If you use .net 2 application settings than the last step is not required. The config file is usable without further action.

jeffreygg
User
Posts: 805
Joined: 26-Oct-2003
# Posted on: 12-Jul-2006 03:29:40   

mihies wrote:

Walaa wrote:

I don't get it?

Are you saying there will be no need for a config file or ini file at least? How the configuration settings should be changed (configured at runtime)? If a file won't be used?

I'll illustrate. You generate the code. The database specific project (I am talking about adapter scenario) has an app.config file which holds default connection string. To use this connection string you have to copy the app.config into exe's app.config file (or web.config). If you use .net 2 application settings than the last step is not required. The config file is usable without further action.

Hi, there. To avoid this issue, I recommend using the override for Adapter's constructor that takes in a connection string. Just set up a simple factory method that injects the appropriate connection string and call that when instantiating a new Adapter.

Jeff

mihies avatar
mihies
User
Posts: 800
Joined: 29-Jan-2006
# Posted on: 12-Jul-2006 09:41:52   

jeffreygg wrote:

Hi, there. To avoid this issue, I recommend using the override for Adapter's constructor that takes in a connection string. Just set up a simple factory method that injects the appropriate connection string and call that when instantiating a new Adapter.

Jeff

Sure. My suggestion would just make the default scenario simplier.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39928
Joined: 17-Aug-2003
# Posted on: 12-Jul-2006 21:03:12   

So if a class lib has a config file, and the .exe hasn't, the config file of the class lib is used?

Frans Bouma | Lead developer LLBLGen Pro
mihies avatar
mihies
User
Posts: 800
Joined: 29-Jan-2006
# Posted on: 12-Jul-2006 22:14:13   

Otis wrote:

So if a class lib has a config file, and the .exe hasn't, the config file of the class lib is used?

Actually application settings always use assembly's config file regardless of assembly type. I used this approach with my Field Setter plugin for example.

pilotboba
User
Posts: 434
Joined: 05-Aug-2005
# Posted on: 13-Jul-2006 00:00:01   

mihies wrote:

If you use .net 2 application settings than the last step is not required. The config file is usable without further action.

What is the difference between application settings and a config file?

mihies avatar
mihies
User
Posts: 800
Joined: 29-Jan-2006
# Posted on: 13-Jul-2006 00:43:04   

application settings thing is something like strong typed config file on steroids. Perhaps you might check .net 2 help files for detailed description. Interestingly, part of its settings is stored in config file.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39928
Joined: 17-Aug-2003
# Posted on: 13-Jul-2006 09:20:48   

that's indeed new to me. I'll check the msdn docs for this, however I think it's logical to simply have the developer focus on the .config file with the connection string, so the configuration data is stored in 1 central place.

Frans Bouma | Lead developer LLBLGen Pro