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.
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.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With