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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T09:51:29+00:00 2026-05-13T09:51:29+00:00

I have a winforms application in which some of the data is stored in

  • 0

I have a winforms application in which some of the data is stored in XML files.
The location where these XML files should be stored can be configured by the user, and is stored in the AppSettings.
All my layers are separate assemblies. Can I access my settings from my DAL assembly, or should I pass this as an argument through all my layers?

When I try to read the settings from my DAL layer, I encounter another problem

        Configuration config = ConfigurationManager.OpenExeConfiguration(
            System.Reflection.Assembly.GetEntryAssembly().Location);
        string dataStorageLocation = config.AppSettings["DataStorageLocation"];

config.AppSettings[“DataStorageLocation”] gives a compilation error: System.Configuration.ConfigurationElement.this[System.Configuration.ConfigurationProperty] is inaccessible due to its protection level. Why is that?

Can someone put me on the right track? Thanks.

  • 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-13T09:51:29+00:00Added an answer on May 13, 2026 at 9:51 am

    You need to use config.AppSettings.Settings["DataStorageLocation"].
    See the MSDN documentation for a sample.

    Alternatively, and IMHO better, you could use System.Configuration.ConfigurationManager.AppSettings[name] to access the AppSettings of the host application. This is probably more flexible than your technique, as it will also work if your DAL assembly is, for example, hosted in a service tier on IIS. Accessing configuration information from the host application’s configuration file directly in this way is perfectly accceptable, and generally better than passing configuration information down through the layers.

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

Sidebar

Related Questions

I have a C#/.NET Winforms application which has some settings stored using A '.settings'
I have a WinForms application that requires some configuration which I do at install
I have an application, which performs some custom data gathering, transformation and reporting. Currently,
We have already shipped a client (.NET WinForms) application which sends customer data to
I have a winforms (C#) application in which will have some settings I want
I have a console application which can also open winform under certain conditions.Processing(its a
We have a winforms application calling a stored procedure every few seconds. The stored
We have a WinForms application that uses SQL server to store its data. To
C# - Winforms - SQL Server i am building an application which displays some
I have a winform application that uses some referenced web services to get data.

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.