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 7696157
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T21:42:51+00:00 2026-05-31T21:42:51+00:00

I have created a Class Library (Core Processing Component) using C# in Visual Studio

  • 0

I have created a Class Library (Core Processing Component) using C# in Visual Studio 2008 and added the reference in Website. Website accessing the class library successfully. Web.config having some configuration values, which is used by the Class Library.

Now, I want to access the same component and configuration in a Window Application (C# VS-2k8). I am able to access the same class library in window application.

But, How do i Share the Web.config file of website with the Window Application? So that, i don’t have to replicate the same configuration.

Thanks.

Update# 1

Further detail on Question 1: I would like to add config file in Class Library instead of having dependent on application’s config file. E.g. web.config in website or app.config in windows application.

This is to reduce the duplicacy/conflicts of same configurations in multiple apps.

Update# 2

I am using the following code to get the configuration from the external location from window and web application. But it is not working for me.

D:\test.exe.config file

<configuration>
  <appSettings>
    <add key="KeyName" value="KeyValue"/>
  </appSettings>
</configuration>

Code Behind:

Configuration config = ConfigurationManager.OpenExeConfiguration("D:\\test.exe.config");
            string strValue = config.AppSettings.Settings["KeyName"].Value;
  • 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-31T21:42:52+00:00Added an answer on May 31, 2026 at 9:42 pm

    Yes, I got the solution.
    Thanks to Bob Horn and JoeBilly for valuable inputs.

    I have implemented the configuration as per my requirement. I have searched a lot for the complete solution but always getting the concepts and small piece of code, that’s why i am providing the complete working code.

    With the help of below mentioned code you can achieve the followings and play with the configuration as you want.

    1. Common Configuration [CommonDB] can be defined as a single
      repository and can be stored in external XML file. Class library will be getting always one value for web as well as windows application.
    2. Website specific configuration [WebDBConn] can be stored in web.config.
    3. Window Application specific configuration [WindowDBConn] can be mentioned in app.config.
    4. If you want to use same Key with Different values [INPUT_PATH] as per the application, then use same key and the diff values in wen.config and app.config. But remember that key should not be available in the common.config other wise the value which is available in the common.config will be picked up.
    5. The good thing is that you don’t have to chage your code behind approach for getting these values.

    Common.Config for Class Library/Common configuration

    <?xml version="1.0" encoding="utf-8" ?>
    <appSettings>
        <add key="CommonDB" value="CommonDBValue" />    
    </appSettings>
    

    Web.Config for Website

    <configuration>
        <appSettings file="D:\Common.config">
            <add key="WebDBConn" value="WebDBConnValue" />
            <add key="INPUT_PATH" value="INPUT_PATH_WEB" />
        </appSettings>
    </configuration>
    

    App.config for Windows Application

    <?xml version="1.0" encoding="utf-8" ?>
    <configuration>
        <appSettings file="D:\Common.config">
            <add key="WindowDBConn" value="WindowDBConnValue" />
            <add key="INPUT_PATH" value="INPUT_PATH_WINDOW" />
        </appSettings>
    </configuration>
    

    Code behind

    string configValue = ConfigurationSettings.AppSettings["CommonDB"];
    

    Thanks…

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

Sidebar

Related Questions

I have a class library project for .NET 3.5 built with Visual Studio 2008.
I have created a class library as a project. Where I have added a
I am using the apache library. I have created a class which sends a
I have created a Class Library (called as GNGEngine.dll) which performs some image processing
I've got a stock standard visual studio 2008 solution with 3 class library projects.
I have created a class library in VB .NET. Some code in the library
I have created a class library called AddServiceLibrary in which I have a method
I have created a class library (assembly) that provides messaging, email and sms. This
I have a silverlight library which I have added a wcf service reference. Call
I have created a class library whcih has simple Dispaly(). I need to use

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.