Tag: .NET

Unable to Open configSource File ‘connections.config’

When specifying the location of a configuration file for a .NET console application you may receive this error:

System.Configuration.ConfigurationErrorsException: Unable to open configSource file 'connections.config'

The file was being referenced as follows in app.config:

<connectionStrings configSource="connectionStrings.config" />

I suspected that the configuration file was not being copied to the ouput debug/release folder and so could not be found when running the application. This post on BlueSam Blog shows that you can set how files are copied to the output directory of the project automatically.

By viewing the properties of a file in Visual Studio there is a property called Copy to Output Directory that can be used to copy the configuration file automatically:

This solved the problem and the configuration file was loaded!

Posted in Everything Else | Also tagged | 3 Comments