Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4030516
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T11:28:54+00:00 2026-05-20T11:28:54+00:00

Is there an equivalent to app.config for libraries (DLLs)? If not, what is the

  • 0

Is there an equivalent to app.config for libraries (DLLs)? If not, what is the easiest way to store configuration settings that are specific to a library? Please consider that the library might be used in different applications.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T11:28:54+00:00Added an answer on May 20, 2026 at 11:28 am

    You can have separate configuration file, but you’ll have to read it "manually", the ConfigurationManager.AppSettings["key"] will read only the config of the running assembly.

    Assuming you’re using Visual Studio as your IDE, you can right click the desired project → Add → New item → Application Configuration File

    This will add App.config to the project folder, put your settings in there under <appSettings> section. In case you’re not using Visual Studio and adding the file manually, make sure to give it such name: DllName.dll.config, otherwise the below code won’t work properly.

    Now to read from this file have such function:

    string GetAppSetting(Configuration config, string key)
    {
        KeyValueConfigurationElement element = config.AppSettings.Settings[key];
        if (element != null)
        {
            string value = element.Value;
            if (!string.IsNullOrEmpty(value))
                return value;
        }
        return string.Empty;
    }
    

    And to use it:

    Configuration config = null;
    string exeConfigPath = this.GetType().Assembly.Location;
    try
    {
        config = ConfigurationManager.OpenExeConfiguration(exeConfigPath);
    }
    catch (Exception ex)
    {
        //handle errror here.. means DLL has no sattelite configuration file.
    }
    
    if (config != null)
    {
        string myValue = GetAppSetting(config, "myKey");
        ...
    }
    

    You’ll also have to add reference to System.Configuration namespace in order to have the ConfigurationManager class available.

    When building the project, in addition to the DLL you’ll have DllName.dll.config file as well, that’s the file you have to publish with the DLL itself.

    Within the VS project, you should set the .config file "Copy to output directory" setting to "Always Copy".

    The above is basic sample code, for those interested in a full scale example, please refer to this other answer.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there a Java equivalent to .NET's App.Config? If not is there a standard
I'm developing a web app for android using jquery_mobile. Is there any equivalent way
Is there an equivalent in .NET to a websphere-style app server? Something that will
Is there an equivalent for modelname_set (a back-referenced property) in Google App Engine's NDB
Is there an F# equivalent to eval? My intent is to have my app
Are there equivalent to perl -c syntax check for JavaScript from command? Given that
Is there an equivalent way of achieving what HTML Tidy does to HTML code
Are there any apps that can show the final configuration as applied to a
I have a web app that currently uses the current HttpContext to store a
Is there an equivalent to HttpUtility.HtmlDecode in WinRT? I'm developing a MetroStyle app and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.