Re: Attach and Access config file for Class Library
From: Nick Malik (nickmalik_at_hotmail.nospam.com)
Date: 10/06/04
- Next message: Jack Wright: "Re: Can I pre-compile dlls on my machine and distribute them?"
- Previous message: Deepankar Raizada: "System.UnauthorizedAccessException: Access is denied"
- In reply to: Murali Krishna. Siruvuru: "Attach and Access config file for Class Library"
- Messages sorted by: [ date ] [ thread ]
Date: Wed, 06 Oct 2004 13:37:14 GMT
The way this is *supposed* to work, the app.config would hold the settings
for all DLLs in the app, and the dll would look to the same config file for
all settings, including the settings for the dll.
On the other hand, this is not always practical. I have a plug-in
architecture in one of my apps, and I need the config files to be specific
to the plug in.
For that purpose, I don't use the config file API. There isn't that much
there anyway.
Just create a simple XML file with the settings for your DLL, store it with
the name of "libraryname.xml" in the application folder (you can include it
in the setup), and have your app simply load the xml file from the
application folder. Use SelectSingleNode() to pick off specific settings.
I would recommend against using the XML file as a resource. The point of
the config file is that the system administrator can change the values in it
to reflect realities in the environment (connection strings, server
locations, database names, stored proc names, file locations, etc), without
requiring the developer to recompile. Placing the settings in a resource
requires a "recompile" of sorts to change any values.
(One advantage of not using the config file API: your app can change the
config file! This advantage will disappear with .NET Framework 2.0, BTW).
I hope this helps,
--- Nick
"Murali Krishna. Siruvuru" <MuraliKrishnaSiruvuru@discussions.microsoft.com>
wrote in message news:DB8CF612-6990-4591-9D5E-066AC6CB8471@microsoft.com...
> Hi,
>
> Is there a way in which we can attach a configuration file for a "Class
> Library Project" and access its values dynamically.
>
> I understand that Class Library would generate a .dll and cannot have
other
> configuration files. But can we add this "App.config" file as a "embedded
> resource" and then access it?
>
> I have used "ConfigurationSettings.AppSettings" and "AppSettingsReader",
> but i am not able to achieve the result.
>
> Appreciate your help
> --
> IT Expert, R&D Department,
> Hanwha S&C, Seoul
- Next message: Jack Wright: "Re: Can I pre-compile dlls on my machine and distribute them?"
- Previous message: Deepankar Raizada: "System.UnauthorizedAccessException: Access is denied"
- In reply to: Murali Krishna. Siruvuru: "Attach and Access config file for Class Library"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|