Solved

How store application settings in a settings file

Posted on 2008-10-04
14
886 Views
Last Modified: 2013-12-17
Hi Experts,

I'm writing a Visual Studio 2005 solution that consists of a Web Service, Windows Service, DLL and an EXE application.  For each of these projects in my solution I store settings that I add through the settings window - In Visual Studio, right-click a project, select properties and then browse to the Settings tab. As far as I know, this edits the app.config file.

My problem is that I wish to allow an administrator to edit settings for all 4 projects (once installed) via the EXE application.  I wish to have one windows form in the EXE thate edits settings for the DLL, the windows service and the web service.

How do I achieve this?
0
Comment
Question by:PantoffelSlippers
  • 8
  • 3
  • 3
14 Comments
 
LVL 26

Accepted Solution

by:
Anurag Thakur earned 100 total points
ID: 22641448
you can create a application from where you can edit the application configurations
get the application configuration files full path and then load it to the xmldocument object and then you can do the operations by selecting the node and modifying the attributes
http://www.codeproject.com/KB/cs/modconfigruntime.aspx
0
 
LVL 70

Assisted Solution

by:Éric Moreau
Éric Moreau earned 200 total points
ID: 22641868
0
 

Author Comment

by:PantoffelSlippers
ID: 22643892
Thanks Eric,

Good to see you back on one of my posts again!

My problem still remains that I have to edit the config file of 3 different projects from one single screen.

As a workaround, I could ask the administrator on-site to rather just edit the config files themselves.  AFter installation, I cannot find the config files in the installation directory.  All my settings are "Application settings".  My folders are set to display hidden and system files.

WHy can't I see the config file?
0
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 
LVL 26

Expert Comment

by:Anurag Thakur
ID: 22643991
search for AssemblyName.EXE.Config files
0
 

Author Comment

by:PantoffelSlippers
ID: 22643998
Thanks ragi0017

I;ll try that now - haven't thought of it.

I do remember editing this file on previous projects I worked on .....
0
 

Author Comment

by:PantoffelSlippers
ID: 22644004
Nope!

I can't find it.  It must be there because if I change settings in Visual Studio, recompile the projects and the setup project and the reinstall the changes are visible in the application behavior so the settings file must be there somewhere.

But I can't find it!
0
 

Author Comment

by:PantoffelSlippers
ID: 22644006
Oh, in my original post I report that I use Visual Studio 2005 when in fact I am using Visual Studio 2008!

Sorry about that.  I do compile to the .net framework 2.0 though...

Not sure if VS2008 works different......
0
 
LVL 70

Expert Comment

by:Éric Moreau
ID: 22644776
everytime you recompile your settings file is recopied to the bin folder. it should be there.

your DLL won't have its settings file, it use the one of the executable that is using it.
0
 

Author Comment

by:PantoffelSlippers
ID: 22645061
Thanks Eric,

I have the config file in the bin folder yes.  My EXE file and DLL install into the same folder on the client machine but there are no config files there ....

So, if I have 5 EXE's sharing the same DLL, I should update the connection strings etc in each of the EXE's config files?
0
 
LVL 26

Expert Comment

by:Anurag Thakur
ID: 22645104
are you sure that when you install your program then the configuration files i.e. AssemblyName.Exe.Config file is not available
If the file is not available then how your settings are being read and acted upon
sounds strange - as far as VS 2005 goes the files exist if i have configured settings for my project to use
dont know much about VS 2008 though
0
 

Author Comment

by:PantoffelSlippers
ID: 22645401
Thanks ragi0017,

>>>>If the file is not available then how your settings are being read

That is exactly my question.  I've changed settings on purpose to see if they are read.  For example, I change the connection string to SQL Server which causes an error to be logged.  When changing it back, it works again so the settings file defenitely installs as well.  I just can't see it to make manual changes....
0
 
LVL 70

Assisted Solution

by:Éric Moreau
Éric Moreau earned 200 total points
ID: 22645427
I think I understand your problem now!

>>I wish to have one windows form in the EXE thate edits settings
>>All my settings are "Application settings".  
>>I just can't see it to make manual changes....

Applications settings cannot be written by the Configuration class at runtime. Only user settings can.

If you need to change those settings (application settings):
-Open the file in Notepad and modify them manually
-Use an application that reads the XML file into a XML document (or LINQ if your in VS2008), modify your nodes and rewrite your file.
0
 

Author Comment

by:PantoffelSlippers
ID: 22814261
OK

Let me go through all once again and then try to close the question ....
0
 

Author Closing Comment

by:PantoffelSlippers
ID: 31503051
Thank you
0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Batch file or script with password 22 44
vb.net 1 month apart 11 30
Powershell File Sort 8 31
VB.net capture  result of a SQL query in variables 3 12
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

803 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question