I have a .NET assembly (.dll) that gets loaded as a COM server into an existing process. How can I get a .config file applied to it such that ConfigurationManager.GetSection
will return the section out of the applied .config file?
views:
44answers:
1
A:
You'll want to use ConfigurationManager.OpenMappedExeConfiguration. There's good code samples in the link, so I won't copy them here.
Harper Shelby
2009-10-29 14:45:50
That just opens up a read/write copy of the .config file for authoring. It doesn't actually apply the .config file to the process such that ConfigurationManager.AppSettings or GetSection reads from that file.
Andrew Arnott
2009-10-29 15:52:47
Nope - it actually forces the application to use the new configuration file. Notice the section near the bottom of the example, where RefreshSection() is called after the changes are made - it's illustrating explicitly that the ConfigurationManager is now pulling data from the mapped configuration file.
Harper Shelby
2009-10-29 16:07:45