application.exe.config file vanishes on compilation

J

Jay Ayliff

If you put configuration settings in a text file in the \bin folder, named
the same as the exe, but with .config (e.g. config file for myapp.exe will
be myapp.exe.config), then the config file is deleted when you build the
exe. If you set the file to readonly then it doesn't get deleted, but of
course then you can't change it from your program! This 'feature' came in
with Visual Studio 2003. In the original VS.NET the config file did not get
deleted.

Has anyone else noticed this, and is there a better way of storing
configuration settings?

Regards

Jay Ayliff
Stalis Ltd
 
H

Herfried K. Wagner [MVP]

* "Jay Ayliff said:
If you put configuration settings in a text file in the \bin folder, named
the same as the exe, but with .config (e.g. config file for myapp.exe will
be myapp.exe.config), then the config file is deleted when you build the
exe. If you set the file to readonly then it doesn't get deleted, but of
course then you can't change it from your program! This 'feature' came in
with Visual Studio 2003. In the original VS.NET the config file did not get
deleted.

Copy the file (named "App.config") to your project's source directory,
add it to the project and select an appropriate build action. The file
will be copied to the "bin" directory automatically when compiling.
 
J

Jay Ayliff

Ah, I should have thought of that myself. I suppose you also need to copy it
back to the source directory from bin if your app changes it?

Jay
 
H

Herfried K. Wagner [MVP]

* "Jay Ayliff said:
Ah, I should have thought of that myself. I suppose you also need to copy it
back to the source directory from bin if your app changes it?

Yes. This new "feature" fixes a bug in VS.NET 2002.
 

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