Help With Multi Project Solution
Hi Guys, first post here and hoping that someone can help me out.
I am currently developing a multi project solution in visual studio. I have 2 main projects that both use the same business logic. I want to be able to use one app.config throughout all my projects. I have been scouring the net for the last day trying to find a solution that works for this, but i am yet to succeed. An outline can be seen below of the code i am using from within my business logic:
public string returnConfigurationValue(string keyName)
{
string configurationValue = string.Empty;
ExeConfigurationFileMap fm = new ExeConfigurationFileMap();
fm.ExeConfigFilename = @"CSITextServiceManagement.exe.config";
Configuration config = ConfigurationManager.OpenMappedExeConfiguration(fm, ConfigurationUserLevel.None);
AppSettingsSection appSettings = AppSettingsSection)config.GetSection("appSettings");
foreach (string key in appSettings.Settings.AllKeys)
{
appSettings.Settings[keyName].Value);
string value = appSettings.Settings[key].Value;
configurationValue += string.Format("{0}{1}", key, value);
}
return configurationValue;
}
My app.config looks like this:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="serviceInterval" value="20000"/>
</appSettings>
</configuration>
When i return and output the contents of the function i get an empty string, which leads me to think that i am not referencing the app.config file properly.
Could someone please advise on how i can resolve this issue as its driving me crazy.