Solved

How store application settings in a settings file

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

DevOps Toolchain Recommendations

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

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Tool Box 2 35
Error on Add method 1 38
Not showing JavaScript in the list 5 39
Replace &lt; with < 14 56
This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.

896 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

21 Experts available now in Live!

Get 1:1 Help Now