I wrote a COM object in c# (a class library that is registered for COM interop), which compiles to a .dll.
I wanted the object to be able to read items from an app.config file (e.g. PmsInterfaceComObject.dll.config). Trouble is, COM interop dll files seem to be hosted by an Application Pool, or other type of .Net executable. Because of this, the configuration provider wants to use the host .Net executable's config file for settings. Not the COM dll's config file.
This is a known issue, this article describes the situation nicely.
I found a way to override the location of the config file at this site. I added some of my own code to discover the location of the running .dll. Here is the result:
AppConfigFilePath = Path
.GetDirectoryName(Assembly.GetExecutingAssembly().CodeBase)
.Replace("file:\\", string.Empty)
+ "\\" + Path.GetFileName(Assembly.GetExecutingAssembly().CodeBase) + ".config";
// Force the location of my App.Config file:
AppDomain.CurrentDomain.SetData("APP_CONFIG_FILE", AppConfigFilePath);
Nice, huh?