|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
DLL Config Filehi,
can a DLL use app.config file just like ASP.NET application ? or any idea how to make DLL is configurable, let say for connection string configuration may be Hendri Hi Hendri,
Yes it is possible to use a configuration/xml file for your DLL. The simplest way of course is to create your own xml file and read from that. The xml file would have your own custom format specific to that DLL. The other way involves a bit more work, and you can read up on it here: http://www.codeproject.com/dotnet/DLLAPPCONFIG.asp HTH Altaf -------------------------------------------------------------------------------- All that glitters has a high refractive index. www.mendhak.com Show quote "Hendri Irawan" <HendriIra***@discussions.microsoft.com> wrote in message news:4C6F4EAB-5656-4FD9-B4BF-0D509104C05B@microsoft.com... > hi, > > can a DLL use app.config file just like ASP.NET application ? or any idea > how to make DLL is configurable, let say for connection string > configuration > may be > > Hendri S.M. Altaf [MVP] wrote:
> Yes it is possible to use a configuration/xml file for your DLL. Hmmm, no it isn't, with the exception of the hack below> The simplest way of course is to create your own xml file and read Yes that is true, but as you note it is configuration for the library's > from that. The xml file would have your own custom format specific > to that DLL. *own types* only. The configuration file for an application is more than just <appSettings> (and config sections) the majority of the file is for settings used by the framework library classes. So if, for example, you want to change the list of trace listeners used by types in a library you have to use the application configuration file. Unless... > The other way involves a bit more work, and you can read .... you do this hack. I quite like it actually, but it is in no way > up on it here: > http://www.codeproject.com/dotnet/DLLAPPCONFIG.asp supported by Microsoft. Just to explain, this page shows how you can change the name of the config file that the application domain reads, and how to tell the appdomain to junk the current configuration settings it has read and hence read the new configuration file the next time config data is requested. This is different to the suggestion above because when framework library classes ask for configuration, they will use the values from the cached hashtable that has been updated. However, note that these new configuration settings will only be read when those classes read the data, which they may not do. For example, the list of trace listeners will be created from the list given in the config file when the appdomain is created, and the config will never be consulted again during the lifetime of the appdomain. IMO this is a weakness of the whole config system in .NET, Microsoft have cached it all in memory, so there is no 'dynamic-ness' as there is with the registry. Richard -- http://www.grimes.demon.co.uk/workshops/fusionWS.htm http://www.grimes.demon.co.uk/workshops/securityWS.htm
Other interesting topics
|
|||||||||||||||||||||||