views:

703

answers:

3

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.

+1  A: 

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
TheVillageIdiot
A: 

Remember to rename the app.config to the name of the exe.

ie. myprogram.exe would have an app.config called myprogram.exe.config

Preet Sangha
+4  A: 

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.

Henk Holterman