I have an existing set of .net libraries that I wish to call from Excel VBA (that part is working fine). These libraries rely on settings in the app.config. I know I can enter these settings in a excel.exe.config file (placed in the same directory as the excel.exe), but this doesn't really seem like a very manageable solution to me, as I can see causing conflicts if more than one application wants to do this.
My question is simple: is there any way of COM exposed dlls referring to their respective config files?
Sample app.config:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="test" value="Hello world!" />
</appSettings>
</configuration>
Sample c#:
namespace ExcelVbaFacingCode
{
public class SimpleAppSettingReader
{
public string GetValue(string key)
{
return ConfigurationManager.AppSettings[key];
}
}
}
Sample VBA:
Public Sub Test()
Dim Test As New SimpleAppSettingReader
Dim sampleValue As String
sampleValue = Test.GetValue("test")
MsgBox "Value: '" + sampleValue + "'", vbOKOnly
End Sub