app.config

P

Phil Hunt

What is difference between app.config and myApp.exe.config.
Do I use the same class (ConfigurationManager.OpenExeConfiguration) to
access them ?

When I use that class, I end up accessing the myApp.exe.config. For my
purpose, I only need a simple variable to keep a running count of something
(like an INI file in VB6 in all I am after). Any suggestion on what I should
use ? I search the web, but they all give partial answer to my question.

Thanks.
 
S

Smithers

The fact that it's a Console app makes no difference.

App.config is the file name prior to compiling (i.e., you add a file to your
project named App.config). When you compile your project, the compiler
copies App.config to the output folder (e.g,. \bin\debug) and renames it to
myApp.exe.config (where myApp is the name of your executable). Beyond
copying and renaming, no changes are made by the compiler.

ConfigurationManager.OpenExeConfiguration is one way to get to it. There are
others. For the best documentation I've found on the .NET 2.0 configuratoin
subsystem (and I have searched extensively), here is a link to the first
article in a comprehensive 3-part series:
http://www.codeproject.com/dotnet/mysteriesofconfiguration.asp

An alternative that might be simpler and easier for your scenario is to go
with project settings.... accessible via Project | Properties | Settings
tab. I haven't used it, but apparently it is perfectly suited for simple
property settings (name/value pairs, etc).

-HTH
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top