the config file

  • Thread starter Thread starter Daniel P.
  • Start date Start date
D

Daniel P.

I have a Windows Forms app in C#.
I created the myApp.exe.config file and it works fine if I just run the exe.

When I try to debug it from Visual Studio it does not see it and throws an
exception.
The .config file resides in the same folder as the source code.

Thanks!
 
Right, you have to copy the config file manually before debugging so that it
loads. When you debug, the program runs from the bin/debug folder.
 
That is very inconvenient. Thanks for info.




Peter Rilling said:
Right, you have to copy the config file manually before debugging so that it
loads. When you debug, the program runs from the bin/debug folder.
 
I have a Windows Forms app in C#.
I created the myApp.exe.config file and it works fine if I just run the exe.

When I try to debug it from Visual Studio it does not see it and throws an
exception.
The .config file resides in the same folder as the source code.

Thanks!

In Solution Explorer, right-click on the project, select Add New Item.
Then scroll to the bottom and select Application Configuration File.
Copy your config file into it.

Austin
 
Hey! It worked fine because the file was read only. If I make it writable it
just disappeared once I try to debug my app. What the &#@% is this?
 
I have experienced the same thing. Probably bugs in VS.NET.

Hopfully a future version will fix these. Maybe VS.NET 2007. :)
 
Daniel P. said:
I have a Windows Forms app in C#.
I created the myApp.exe.config file and it works fine if I just run the exe.

When I try to debug it from Visual Studio it does not see it and throws an
exception.
The .config file resides in the same folder as the source code.

Thanks!

Are you really creating a file with the name "myApp.exe.config"?
There might be the problem. In VS you can create a file with the
(fixed) name "app.config", which gets copied and renamed
to the correct directory (debug or release) and filename
(myApp.exe.config) when you build the project.

Hans Kesting
 
That's it!
Thanks a lot!

Hans Kesting said:
Are you really creating a file with the name "myApp.exe.config"?
There might be the problem. In VS you can create a file with the
(fixed) name "app.config", which gets copied and renamed
to the correct directory (debug or release) and filename
(myApp.exe.config) when you build the project.

Hans Kesting
 
That is very inconvenient. Thanks for info.

Just add a text file called "app.config" (exactly that - do NOT
replace "app" with your app's name or anything!) to your project -
VS.NET will automagically rename it to "yourapp.exe.config" and copy
it to whether your compiler output goes.

Marc
================================================================
Marc Scheuner May The Source Be With You!
Bern, Switzerland m.scheuner(at)inova.ch
 
I did that as Hans said but there is still an issue. If I make changes and
save to the .config file created in th debug folder then those changes are
lost because they are not copied back to the App.config file.

Is there a solution to this problem?
 
Daniel P. said:
I did that as Hans said but there is still an issue. If I make changes and
save to the .config file created in th debug folder then those changes are
lost because they are not copied back to the App.config file.

Is there a solution to this problem?
Always update the App.config (and rebuild :-)

/LM
 
Back
Top