Re: Attach and Access config file for Class Library

From: Nick Malik (nickmalik_at_hotmail.nospam.com)
Date: 10/06/04


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



Relevant Pages

  • Re: WSE 3.0 settings
    ... I think WSE should apply settings on fly. ... should look for the settings in the calling assembly config file (Calling ... I want to use third party DLL (Or I have to develop a DLL to be used in ...
    (microsoft.public.dotnet.framework.webservices.enhancements)
  • Handling of App.config Files in Solution with some Subprojects
    ... And maybee someone finds it interesting ... ... Project Network (DLL) with app.config ... The settings in the other files are compiled into the DLLs and thanks to Lutz Roeder I can find it there in the CompilerGenerated internal sealed class Settings. ... I made a config file for easy changeing that values ... ...
    (microsoft.public.dotnet.general)
  • Re: Starting up application from dll.
    ... The config file gets its name from the .EXE, ... It is often the case that the DLL provides services ... how does the dll find it's XML file? ... This is convenient when transferring your app from dev to test to ...
    (microsoft.public.dotnet.framework)
  • Re: Starting up application from dll.
    ... > The config file gets its name from the .EXE, ... > their settings from the config file for the EXE. ... > differently for each application that uses the DLL. ... then you can create an XML file that the DLLs will use. ...
    (microsoft.public.dotnet.framework)
  • Re: appsetting in class doesnt work
    ... In 2003 I could easily change the config file settings from inside the app, ... Dim cnfg As System.Configuration.Configuration ...
    (microsoft.public.dotnet.languages.vb)