Gustav Brock
Gustav at cactus.dk
Fri Feb 29 07:22:06 CST 2008
Hi Charlotte et al OK, I'm a child of VS2005, and when creating data sources the wizard kindly asks if you wish to save the connection strings in a file. Yes please, and that file happens to be app.config which you can read and write via the GUI. Now I realize that this file has entries for application settings as well as user settings where the main difference is that the application settings are read-only during runtime. This, of course, limits the value of using the application settings as you may have a need to store or edit application setting entries during runtime. I don't like to reinvent the wheel so I wondered if any method exists to circumvent this limitation other than to create a separate system as you have done. The only method I have seen is to open the app.config XML file directly as any other XML file: http://www.ryanfarley.com/blog/archive/2004/07/13/879.aspx To complicate matters, an advice is _not_ to do that because - as I mentioned previously - if the app.config file is read-only, it might be for a reason. That reason is explained here: http://www.interact-sw.co.uk/iangblog/2004/11/25/savingconfig where the author claims that one should never write files into the Program Files folder ..(!) .. but use the Application Data folder of the user. That may be true, and I sure want to behave, but the next question is then: Where to store config files and such common for all users? Would that be: C:\Documents and Settings\All Users\Application Data\YourApp So, where do you store your application data common for all users? /gustav >>> cfoust at infostatsystems.com 28-02-2008 18:28 >>> OK, you've totally lost me. We don't reference either of those files, and why should we? All (or virtually all) of the contents are created as we build the application. The only time we modify our app.config is to handle a DataDynamics licensing issue on our onw workstations. Geeks notwithstanding, settings only apply at runtime, and we can control those nicely with xml files. We store our connection strings in an xml file, not in app.config, and read them when we need them. Obviously, userIDs and passwords are NOT stored in the xml file. I still have the feeling we're talking about two different things here. Charlotte Foust -----Original Message----- From: dba-vb-bounces at databaseadvisors.com [mailto:dba-vb-bounces at databaseadvisors.com] On Behalf Of Gustav Brock Sent: Thursday, February 28, 2008 9:02 AM To: dba-vb at databaseadvisors.com Subject: Re: [dba-VB] VS2005: Storing application settings Hi Charlotte It is the app.config xml file for application settings like Connection strings and so on: C:\...\Visual Studio 2005\Projects\<project>\<project>\app.config It holds the entries from the menu Project, <project> Properties pane, tab Settings. Nothing wrong with XML files. It's just that it seems that this file is for VS's use, so don't tamper with it. If you reference System.Configuration you can easily read from it via code, and methods exists for editing and saving values for _users_, however nothing can be saved for the _application_: http://geekswithblogs.net/akraus1/articles/64871.aspx /gustav >>> cfoust at infostatsystems.com 28-02-2008 17:01 >>> Are you talking about settings for Visual Studio or settings for an application? We use XML files for storing application settings (not VS settings), Gustav. I don't know why you characterize it as clumsy, and we don't "attack" any xml files. Charlotte Foust -----Original Message----- From: dba-vb-bounces at databaseadvisors.com [mailto:dba-vb-bounces at databaseadvisors.com] On Behalf Of Gustav Brock Sent: Wednesday, February 27, 2008 6:19 AM To: dba-vb at databaseadvisors.com Subject: [dba-VB] VS2005: Storing application settings Hi all How do you store application settings? I've noticed the nice pane with the tab "Settings" for manually doing this, but it is read-only from code. Of course you can step down and attack the xml file storing the data, but I find that a bit clumsy. /gustav