|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
|
Announcements
Chapters
Services
Feature Zones
|
IntroductionI'll explain how to build a BackgroundWhen you deploy .dll assemblies (especially for ASP.NET applications), you are forced to use the main application's configuration file. Some of my applications have a lot of entries to add to the The codeTo access the configuration file, the following class returns a custom public class CustomConfigurationSettings
{
public static AppSettingsReader AppSettings(string configFile)
{
return new AppSettingsReader(configFile);
}
}
You can call it in your code like this: object settingsValue =
StaticDust.Configuration.CustomConfigurationSettings.AppSettings(
"C:\\yourFile.config")["yourKey"];
To get the file named {yourAssembly}.config in a web application, call it as follows: Assembly assmebly = Assembly.GetExecutingAssembly();
string configFile =
System.Web.HttpContext.Current.Request.PhysicalApplicationPath +
"bin\\" + assmebly.GetName().ToString().Split(',')[0] + ".config";
object settingsValue =
StaticDust.Configuration.CustomConfigurationSettings.AppSettings(
configFile)["yourKey"];
History
|
||||||||||||||||||||||