Vanishing .exe.config files

J

Jay Ayliff

I'm embarrassed to say I asked this before but the original answer scrolled
off the list.

I use configuration files with my VB.NET winforms apps. The application is
configured to find them in the same folder as the executing assembly, and
with the same name, but with '.config' at the end. Trouble is, when you
compile the application it deletes everything that was in the \bin folder,
including the config file. I thought the fix was to include the config file
in the solution, and the compile process will copy the file to the \bin
folder each time. I tried this and the file does not get copied. In the
Properties window for the file there are four options for Compile Action:
None, Compile, Content and Embedded Resource. I find that Compile treats the
file as VB source and throws errors, while the other three do not copy the
file to the \bin folder.

Can anyone tell me what I am doing wrong?

Regards

Jay Ayliff
Stalis Ltd
 
H

Herfried K. Wagner [MVP]

* "Jay Ayliff said:
I'm embarrassed to say I asked this before but the original answer scrolled
off the list.

I use configuration files with my VB.NET winforms apps. The application is
configured to find them in the same folder as the executing assembly, and
with the same name, but with '.config' at the end. Trouble is, when you
compile the application it deletes everything that was in the \bin folder,
including the config file. I thought the fix was to include the config file
in the solution, and the compile process will copy the file to the \bin
folder each time. I tried this and the file does not get copied. In the
Properties window for the file there are four options for Compile Action:
None, Compile, Content and Embedded Resource. I find that Compile treats the
file as VB source and throws errors, while the other three do not copy the
file to the \bin folder.

Rename the file to "App.config" and add it to your project, then set its
Build Action to an appropriate value. VS.NET will automatically copy
the file over to the "bin" folder and rename it to the proper name.
 
J

Jay Ayliff

Ah, you have to call it App.config! What confused me was having the file
change its name to <exename>.exe.config on. But I suppose it's sensible to
do it like that as you can change the name of the assembly in
Project/Properties, but you don't really want to change the name of the file
in the project.

Many thanks,

Jay Ayliff
Stalis Ltd
 

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