A UI to edit/view config files for .NET Apps

Hello World,

I was wondering if I could provide my deployment team with a nice UI that would present app.config or web.config AppSettings section for viewing or editing. After some deliberation, I fired up my Visual Studio and started playing around with the methods of the Configuration class (found under the System.Configuration namespace). I noticed a method called OpenExeConfiguration that looked promising; it had all the methods that looked like having the ability to traverse the config file and read/write key value pairs.
Each discovery though comes with issues! I tried several ways of accessing the config file from another app but no matter what I tried, the HasFile method of Configuration class would return “false” indicating that there was no config file in the location I specified!! Then I began googling (what else would you do?!) and found this useful link: Blog Post
It appears that you need to tell the OpenExeConfiguration method where the EXE is and it will try to locate the config file by concatenating the exe name with “.config”. E.g., if your exe is called MySuperApp.exe and could be found in the directory C:\, you would write something like this:

Configuration conf = ConfigurationManager.OpenExeConfiguration(@”C:\MySuperApp.exe”);

Once I am through writing this UI app, I will try posting the code in this blog.

Until next time,
System.AllIsWell = true;

Posted in Uncategorized
One comment on “A UI to edit/view config files for .NET Apps
  1. SM says:

    NOTE: For building a UI for web-apps, use OpenWebConfiguration method instead of OpenExeConfiguration.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

  • Comic for July 25, 2017
    Dilbert readers - Please visit Dilbert.com to read this feature. Due to changes with our feeds, we are now making this RSS feed a link to Dilbert.com.
%d bloggers like this: