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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T22:53:27+00:00 2026-05-10T22:53:27+00:00

I’m trying to abstract out all database code into a separate library and then

  • 0

I’m trying to abstract out all database code into a separate library and then use that library in all my code. All database connections are done using typed TableAdapters that I create by dragging and dropping in datasets in VS2005, using a connection string from the appSettings.

The problem that I haven’t been able to solve is that .Net doesn’t propagate the libraries appSettings to the other project that’s using it.

In short, I have a database layer library, MyProgram.DbLayer, which is used by other projects such as MyProgram.Client etc. When I had all the datasets in the .Client the connectionString was in MyProgram.Client.exe.config so that I could change it after build. When I moved it into the MyProgram.DbLayer that setting isn’t avaliable to me after I build the binaries.

EDIT: This seems to be a more general issue with ApplicationSettings.

What I noticed was that if I manually add a setting only used in a library it will be properly read. The only thing I need now is for the setting to be automatically included in the .config file as well.

  • 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. 2026-05-10T22:53:28+00:00Added an answer on May 10, 2026 at 10:53 pm

    AppSettings/ConnectionStrings will always be read from the currently running app pool.

    By this I mean:

    If I have A.exe which has a class DAL.cs. DAL.cs reads a connection string from config, and it returns "abc" as expected.

    I then move DAL.cs to its own project, and thus, its own assembly. I can still have it call the connection string from app.config, however, I will need to "host" the assembly in a running application, and add the connection string to that applications app config. So, I create a new app.config and specify the connection string "xyz" in it, when it runs, it runs as expected.

    Now, if I change the reference in the A.exe project to use the new DAL.dll, what connection string do you think it will have? "xyz"? Nope! It will use the "abc" as it did before because that is still configured in the application configuration file for A.exe.

    I know this works because I used shared DAL code across many Windows and Web applications.

    If any of this is unclear, or does not help your problem, please let me know by commenting on this answer.

    Update following comment from OP

    By "host" I mean an application that is calling on the common code. This can be a Windows or a Web application, basically it is the application context.

    You will need to create entries in the configuration files for each application that uses the common code. If I misunderstood your original question (entirely possible, it’s been a long day!) and you wish to centralize the configuration as well, then you would need to:

    • Create some form of centralised storage (be it XML, DB, whatever).
    • Enhance your common code to have default values to enable it to connect to the centralised storage.
    • From there, the code can then configure itself, based on the information in the configuration store.

    Hope this helps 🙂

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

Sidebar

Ask A Question

Stats

  • Questions 110k
  • Answers 110k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer If I understand correctly, you want users to upload a… May 11, 2026 at 9:31 pm
  • Editorial Team
    Editorial Team added an answer From the main MSDN subscription page you can access the… May 11, 2026 at 9:31 pm
  • Editorial Team
    Editorial Team added an answer There is no single Microsoft style, although there have been… May 11, 2026 at 9:31 pm

Related Questions

I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
I am currently running into a problem where an element is coming back from
Seemingly simple, but I cannot find anything relevant on the web. What is the
Configuring TinyMCE to allow for tags, based on a customer requirement. My config is
Is it possible to replace javascript w/ HTML if JavaScript is not enabled on

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.