I'm working on a dll (MyExtension.dll) that will be an extension for a host application. When the host application launches it recognizes the dll and makes the functionality available to the user. My dll has a .config file (MyExtension.dll.config) that sits beside the dll. In the config file I have various sections for some settings. A simplified example is below:
<configSections>
<section name="categories" type="System.Configuration.NameValueSectionHandler"/>
</configSections>
<categories>
<add key="names", value="beam,column,girder"/>
</categories>
I created a function that will point to my .config file
public static List<string> GetCategorieNames()
{
string path =Assembly.GetExecutingAssembly().Location;
Configuration appConfig = ConfigurationManager.OpenExeConfiguration(path);
categories section = appConfig.GetSection("categories") as categories;
List<string> categoryList = new List<string>();
categoryList.AddRange(Array.ConvertAll(section.KeyName.Split(','), s => s.Trim()));
return categoryList;
}
When I put a breakpoint and debug the appConfig variable, it's file path is pointing to the correct location that I want it to read data from. But when I continue to debug further, it contains sections from some other configuration document (not quite sure where).
What is the correct way to reference a .config file that is not the host application's?