Solved

How store application settings in a settings file

Posted on 2008-10-04
14
887 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
How Do You Stack Up Against Your Peers?

With today’s modern enterprise so dependent on digital infrastructures, the impact of major incidents has increased dramatically. Grab the report now to gain insight into how your organization ranks against your peers and learn best-in-class strategies to resolve incidents.

 
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

Resolve Critical IT Incidents Fast

If your data, services or processes become compromised, your organization can suffer damage in just minutes and how fast you communicate during a major IT incident is everything. Learn how to immediately identify incidents & best practices to resolve them quickly and effectively.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Latest thoughts on C# utilizing Mono on Linux vs .NET on Windows? 5 64
How to limit User Input 2 27
JSON Deserialize issue 6 26
how to just get time from a date 6 33
Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

838 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