Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Register Tags Active Topics RSS Search Mark Forums Read

Sponsored Links



Modify app.config in C# application

Software Development


Reply
 
Thread Tools Search this Thread
  #1  
Old 11-04-2009
Member
 
Join Date: Feb 2008
Posts: 624
Modify app.config in C# application
  

I am newbie in C# application that uses the app.config file to set up various things: for example, the path to store the files on the workstation on which the application is installed.

Can we, after installing the program manually modify app.config to change the values associated with keys? For now the application does not include my changes ...

Apparently this is not the right way to go ... So how do handle this sort of thing?

Reply With Quote
  #2  
Old 11-04-2009
Member
 
Join Date: May 2008
Posts: 2,291
Re: Modify app.config in C# application

Well you can add/modify keys or values in your file app.config (it is for that), but it still requires that the application is coded to reflect these changes. If you added to such a tag <user name="foo" password="password"/>, we must know that your application is likely to have a <user> with attributes in the app. config
Reply With Quote
  #3  
Old 11-04-2009
Member
 
Join Date: Feb 2008
Posts: 624
Re: Modify app.config in C# application

thank you, but still how ...

1) on my dev platform, my application gets the value of a variable <add key="path" value="c:\thing"> stored in app.config with ConfigurationManager.AppSettings["path"].OK.

2) on a pc user who installs the application, the value of "path" should be changed to "c:\widget".

The thing is, I manually alter the app.config placed in the directory where the application is installed, and that it completely ignores the new value of "c:\widget".

In fact, I try just to have a good old file .ini ...
Reply With Quote
  #4  
Old 11-04-2009
Member
 
Join Date: May 2008
Posts: 2,291
Re: Modify app.config in C# application

In the directory where you installed your Application, the app. config must be under the name "yourApplic.exe.config". it is not called "app.config" once compiled.

Sorry I had forgotten this detail
Reply With Quote
  #5  
Old 05-05-2009
Member
 
Join Date: May 2009
Posts: 1
Re: Modify app.config in C# application

Quote:
Originally Posted by Sean J View Post
I am newbie in C# application that uses the app.config file to set up various things: for example, the path to store the files on the workstation on which the application is installed.

Can we, after installing the program manually modify app.config to change the values associated with keys? For now the application does not include my changes ...

Apparently this is not the right way to go ... So how do handle this sort of thing?
It depends that in which type of project you added your config file.
If the app.config file was originally created in a dll project , you wont be able to edit the values(or you cannot use it , even if you edited).
Instead if the app.config file is in exe project , (\MyProject\bin\Debug\myproject.exe.config) , then it is possible to edit the values , and use the new values at runtime.
Reply With Quote
  #6  
Old 18-07-2009
Pablo Romano
 
Posts: n/a
Re: Modify app.config in C# application

Hi, after a lot of struggling I found a way to change the settings in a dll without recompiling and wrote a post about it, if you are having trouble changing them in the main app I also added a Demo that may help you.

http://moebiusit.com/blog/pabloroman...-re-compiling/
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: , , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "Modify app.config in C# application"
Thread Thread Starter Forum Replies Last Post
how to make application for changing/modify file permission dinafrinsi Software Development 1 28-04-2012 02:43 PM
Config.xml not specified. Valid config.xml file must be authored when deploying '(null)' Error 25004 Jaiya Operating Systems 8 18-04-2011 09:09 AM
Error parsing c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\config\machine.config on startup Jaiya Operating Systems 5 17-04-2011 09:51 AM
Difference between Web.Config and Machine.Config File Adrina_g Software Development 5 23-01-2010 02:44 PM
How to do web.config for an application Pandya Software Development 3 06-03-2009 11:19 AM


All times are GMT +5.5. The time now is 08:01 PM.