I\'m trying to reference some common config settings between a Windows Service and an ASP.NET MVC website. I am doing this by using the file attribute on appSettings in eit
I use this to access another .exe's config file, not sure whether it will work with a MVC project, but this might get you closer:
string proj2Exe = @"C:\projects\proj2\bin\Debug\proj2.exe";
Configuration proj2Config = ConfigurationManager.OpenExeConfiguration(proj2Exe);
string mysetting = proj2Config .AppSettings.Settings["ThatSetting"].Value;
The idea of using "bin/..." is good but leads to an error saying that "/" is an invalid character in the resulting virtual path.
The proper solution is tu use "bin...".
Cheers
In the Web.Config you must add "bin/" (se example below).
By default the web.config is NOT copied into the bin folder but the file common.config is, therefore you must add the path from web.config. In a non-web project the default behavior is that the App.config is copied to the bin folder with name MyProgram.exe.config and is in the same directory as common.config.
<appSettings file="bin/common.config">