ComVisible
regasm /codebase "assembly_path"
MyAssemblyName.dll.config
) which are in assembly's folderConfigurationManager.AppSettings["SettingName"]
CreateObject("...")
ConfigurationManager.AppSettings["SettingName"]
returns null. It looks like assembly doesn't see config file. What should I to do to make it workable?
One possible way, as Komyg said, is to read config file directly, instead of using ConfigurationManager's embedded behavior. For those, who will have the same problem: instead of
ConfigurationManager.AppSettings["SettingName"]
you can use:
var _setting = ConfigurationManager.AppSettings["SettingName"];
// If we didn't find setting, try to load it from current dll's config file
if (string.IsNullOrEmpty(_setting))
{
var filename = Assembly.GetExecutingAssembly().Location;
var configuration = ConfigurationManager.OpenExeConfiguration(filename);
if (configuration != null)
_setting = configuration.AppSettings.Settings["SettingName"].Value;
}
This way you will always use read settings from file YourAssemblyName.dll.config
which lays in your assembly's folder. It will allow you to use also another features for app.config
(like appSetting
's file
attribute), which will no be available if you will use XPath or something like this.