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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T02:05:17+00:00 2026-05-28T02:05:17+00:00

I have a class library used in windows (WPF) and web (ASP.NET) context. The

  • 0

I have a class library used in windows (WPF) and web (ASP.NET) context. The library has settings that are rather user-scoped, if used in windows context and that have to be application-scoped, if used in web context. I would like to declare them as user-scoped and use the default values as “pseudo-application-scoped”. My problem is, that web applications ban user-scoped settings by throwing a configuration error.

What is the best way to handle this, preferably within the frameworks configuration system?

  • 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-28T02:05:18+00:00Added an answer on May 28, 2026 at 2:05 am

    Ok, facing the unavoidable. There are no user-scoped settings in ASP.NET. Class libraries used in mixed client / server environments shouldn’t use them!

    Here is the solution I ended with:

    For the usage in a server environment (ASP.NET) all settings of class libraries have to be application-scoped.

    I introduce a second set of settings for the usage in client environments (WPF). These settings have property names and types identical to the class libraries property names and types, but they can differ in scope and they are located in my main assembly.

    With a small piece of code I extend the libraries setting class to inject the user-scoped settings.

    namespace ClassLibrary.Properties 
    {
        using System.Configuration;
    
        public sealed partial class Settings {
            private ApplicationSettingsBase injectedSettings;
    
            public void InjectSettings(ApplicationSettingsBase settings)
            {
                injectedSettings = settings;
            }
    
            public override object  this[string propertyName]
            {
                get 
                { 
                    if (injectedSettings != null)
                        return injectedSettings[propertyName];
    
                     return base[propertyName];
                }
                set 
                { 
                    base[propertyName] = value;
                }
            }
        }
    }
    

    With this extension I can inject the second settings class into the library settings:

    ClassLibrary.Properties.Default.InjectSettings(Application.Properties.Settings.Default);
    
    • 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 (.NET) with a reference to a web service (in
I am used to Visual studio, I have class library projects that I reference
I have a .NET class library containing a class with a method that performs
I have an assembly (.NET class library) that contains an object that implements EAP
We have a class library where we keep a lot of the stuff that
I have a class library project that references the version 4.1 Microsoft.Practices.Common dll. I
My Scenario I have a class library that is going to be called from
Using .NET 2.0, C#, Windows Forms development, Enterprise Library 3.1. We have a project
My one ASP.NET web site uses two different business object class libraries. There is
I have a class library with some extension methods written in C# and an

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.