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.


  1. Fatal error: Uncaught Error: Call to undefined function ereg() in /home/brightfunction/brightfunction.co.uk/wp-content/themes/thematic/library/extensions/comments-extensions.php:175 Stack trace: #0 /home/brightfunction/brightfunction.co.uk/wp-content/themes/thematic/library/extensions/discussion.php(10): thematic_commenter_link() #1 /home/brightfunction/brightfunction.co.uk/wp-includes/class-walker-comment.php(174): thematic_comments(Object(WP_Comment), Array, 1) #2 /home/brightfunction/brightfunction.co.uk/wp-includes/class-wp-walker.php(145): Walker_Comment->start_el('', Object(WP_Comment), 1, Array) #3 /home/brightfunction/brightfunction.co.uk/wp-includes/class-walker-comment.php(135): Walker->display_element(Object(WP_Comment), Array, '5', 0, Array, '') #4 /home/brightfunction/brightfunction.co.uk/wp-includes/class-wp-walker.php(370): Walker_Comment->display_element(Object(WP_Comment), Array, '5', 0, Array, '') #5 /home/brightfunction/brightfunction.co.uk/wp-includes/comment-template.php(2097): Walker->paged_walk(Arra in /home/brightfunction/brightfunction.co.uk/wp-content/themes/thematic/library/extensions/comments-extensions.php on line 175