Disappearing config file

  • Thread starter Thread starter Adam Smith
  • Start date Start date
A

Adam Smith

Whenever I try to start my service application, the config file is
erased and I get an application exception trying to read it. When I
make it read only, everything is fine.

Anyone know why this erasing happens in the bin\debug directory?

Thanks.

Adam Smith
 
Adam said:
Whenever I try to start my service application, the config file is
erased and I get an application exception trying to read it. When I
make it read only, everything is fine.

Anyone know why this erasing happens in the bin\debug directory?

Thanks.

Adam Smith

If you're using VS.NET 2003, it's probably erasing the config file with
each build.

Add a file to your project called "App.config" and place your config
contents in there.

VS.NET will copy that file to the build directory and rename it
appropriately.
 
Whenever I try to start my service application, the config file is
erased and I get an application exception trying to read it. When I
make it read only, everything is fine.
Anyone know why this erasing happens in the bin\debug directory?

Because it was designed to do this?

What did you call your config file? Did you add it to your VS.NET
project?

The trick is to add a text file called "app.config" - exactly that, no
replacements or changes to the name!!!!! - and then VS.NET will always
rename it to <yourapp.exe.config> and place it in your output bin
directory for you.

VS.NET 2003 even has a "Add New Item > Utility > Application
configuration file" menu item, which does exactly that - add a text
file called "app.config" to your current project.

Marc

================================================================
Marc Scheuner May The Source Be With You!
Bern, Switzerland m.scheuner(at)inova.ch
 
Where do I originally place this "app.config" file, and do I substitute
my application name in the "app" part?

Thanks.

Adam Smith
 
Just right-click your project, select Add | Add New Item... Look through to
the bottom of the list shown, you'll see "Application Configuration File".
Choose it, and leave it named as "app.config" (not your application name).

When you do a build, vs.net will rename it to yourapp.exe.config, and copy
it to the output directory.
 
Back
Top