Solved

How store application settings in a settings file

Posted on 2008-10-04
14
884 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 69

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
 
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
Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

 
LVL 69

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 69

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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

760 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now