.NET Config Files configSource outside the application directory folder
Solution 1:
Another solution is simply to add the configuration file in all your projects as a link instead of actually copying the file to your projects. Then set the "Build Action" of the file to "Content" and "Copy to Output Directory" to "Copy if newer" and when you compile the project you will have the file in the output directory.
To add the file as a link in the "Add Existing Item" dialog box, there is an Add button with a dropdown. Choose "Add as link" from the dropdown on the Add button to complete the process.
Solution 2:
Under appSettings you can use file= instead of configSource=
Solution 3:
It seems that's that is the way it is. configSource must be in the same folder or deeper.
You could, although I'm not sure you should, use an NTFS hardlink. [mad grin]
Solution 4:
Visual Studio 2015
If you are having this issue with Web.Config the accepted answer is correct but just to expand since this had me giving myself the face-palm:
When you add a .config file to your project using 'Add As Link' and then set the link's Copy property to 'Copy If Newer' or 'Copy Always', then the physical file will be copied to the /bin folder.
Thus, when you have a config section defined in Web.Config like this:
<section name="mySpecialConfig" type="System.Configuration.AppSettingsSection" requirePermission="false" />
then you must define the related config element like this:
<mySpecialConfig configSource="bin\MySpecialConfig.config">
</mySpecialConfig>
such that the configSource points to the physical bin\MySpecialConfig.config file not to the link Also, note that the path is a relative physical path.
That may seem ridiculously obvious but if you haven't done this before the physical file is not yet in the \bin folder so it may not click right away.