Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

c# winapp add app.config to installer?

Okay I've got my app.config file that is containing my database settings.

All works well on my development machine. But when I install it on a test machine I'm getting a null reference on the following line:

ConnectionString = ConfigurationManager.ConnectionStrings["MyDBConn"].ToString();

Why is this happening? I guess that the app.config file isn't found. But isn't this included when you build the setup?

I'm using a very simple setup project in VS2008.

like image 830
Gerbrand Avatar asked Aug 24 '09 10:08

Gerbrand


2 Answers

The file app.Config is your source, don't distribute it. When Visual Studio builds your project it copies the file to {AppName}.exe.config (in the same folder as {AppName}.exe ) and that is the file you need to include in your setup.

like image 194
Henk Holterman Avatar answered Sep 30 '22 02:09

Henk Holterman


Select app.config in solution explorer and in the properties tab choose the copy action:

Copy to Output Directory -> Copy always 

or

Copy to Output Directory -> Copy if newer
like image 30
TheVillageIdiot Avatar answered Sep 30 '22 02:09

TheVillageIdiot