the config file

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!
 
P

Peter Rilling

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.
 
D

Daniel P.

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.
 
A

Austin Ehlers

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
 
D

Daniel P.

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?
 
P

Peter Rilling

I have experienced the same thing. Probably bugs in VS.NET.

Hopfully a future version will fix these. Maybe VS.NET 2007. :)
 
H

Hans Kesting

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
 
D

Daniel P.

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
 
M

Marc Scheuner [MVP ADSI]

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
 
D

Daniel P.

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?
 
L

Luc E. Mistiaen

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
 

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