Solved

How store application settings in a settings file

Posted on 2008-10-04
14
888 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Forrester Webinar: xMatters Delivers 261% ROI

Guest speaker Dean Davison, Forrester Principal Consultant, explains how a Fortune 500 communication company using xMatters found these results: Achieved a 261% ROI, Experienced $753,280 in net present value benefits over 3 years and Reduced MTTR by 91% for tier 1 incidents.

Question has a verified solution.

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

In my previous article (http://www.experts-exchange.com/Programming/Languages/.NET/.NET_Framework_3.x/A_4362-Serialization-in-NET-1.html) we saw the basics of serialization and how types/objects can be serialized to Binary format. In this blog we wi…
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 …
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…
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

756 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