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!

This entry was posted in Everything Else and tagged , . Bookmark the permalink. Post a comment or leave a trackback: Trackback URL.

3 Comments

  1. Vince
    Posted September 20, 2013 at 7:54 pm | Permalink

    +1, solved my problem, thanks!

  2. leon
    Posted June 16, 2014 at 3:40 pm | Permalink

    +2, solved the problem too, thanks.

  3. Mohana Reddy Bindela
    Posted December 17, 2015 at 10:17 am | Permalink

    Solved the problem. Thanks you!

Post a Comment

*
*
*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

* = Required