I have the following code.
I am doing this in the post build event, the below class is getting executed but it is unable to make any access to appsettings.
I tried all combinations like giv开发者_JAVA技巧ing absolute path and accessing through configurationmanager, but nothing worked.
The below class is inside the project where we have web.config and appsettings.
Can you please tell me what can be the issue.
TestResources:AppDomainIsolatedTask
{
private NameValueCollection constants = (NameValueCollection)ConfigurationManager.GetSection("applicationSettings/applicationConstants");
public override bool Execute()
{
constants.Get("VersionNo")
}
}
Have you tried something like this?
var fileMap = new System.Configuration.ExeConfigurationFileMap { ExeConfigFilename = "path to config" };
var config = System.Configuration.ConfigurationManager.OpenMappedExeConfiguration(fileMap, ConfigurationUserLevel.None);
var section = (NameValueCollection)config.GetSection("name of section");
精彩评论