We have an ‘engine’ that loads dlls dynamically (whatever is located in a certain directory) and calls Workflow classes from them by way of reflection.
We now have some new Workflows that require access to a database, so I figured that I would put a config file in the dll directory.
But for some reason my Workflows just don’t see the config file.
<configuration> <appSettings> <add key='ConnectString' value='Data Source=officeserver;Database=mydatabase;User ID=officeuser;Password=officeuser;' /> </appSettings> </configuration>
Given the above config file, the following code prints an empty string:
Console.WriteLine(ConfigurationManager.AppSettings['ConnectString']);
I think what I want is to just specify a config filename, but I’m having problems here. I’m just not getting results. Anyone have any pointers?
If your code sample for reading the AppSettings is in your DLL, then it will attempt to read the config file for the application and not the config file for the DLL. This is because you’re using Reflection to execute the code.