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!
3 Comments
+1, solved my problem, thanks!
+2, solved the problem too, thanks.
Solved the problem. Thanks you!