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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T16:31:41+00:00 2026-06-15T16:31:41+00:00

In a .NET application, if you have specific Settings need, such as storing them

  • 0

In a .NET application, if you have specific Settings need, such as storing them in DB, then you could replace LocalFileSettingsProvider with a custom settings provider of your, examples:

Create a Custom Settings Provider to Share Settings Between Applications

Creating a Custom Settings Provider

To declare the settings class (the one that inherits ApplicationSettingsBase) that you want to use a specific provider, you decorate it with SettingsProviderAttribute and pass your provider type as a parameter [SettingsProvider(typeof(MyCustomProvider))], otherwise it will use the default LocalFileSettingsProvider.

My question: Is there a configuration or a trick I could use to force my application to use my custom provider through-out the application without using an attribute?

The reason is that I am loading plugins via MEF and the plugins might be written via 3rd party and I don’t want them to be concerned with how settings are being dealt with.

  • 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-06-15T16:31:43+00:00Added an answer on June 15, 2026 at 4:31 pm

    You could try the following code. It basically changes the default provider to an arbitrary one during the construction of the Settings object. Note that I never tested this code.

    internal sealed partial class Settings {
    
        public Settings() {
    
            SettingsProvider provider = CreateAnArbitraryProviderHere();
    
            // Try to re-use an existing provider, since we cannot have multiple providers
            // with same name.
            if (Providers[provider.Name] == null)
                Providers.Add(provider);
             else
                provider = Providers[provider.Name];
    
            // Change default provider.
            foreach (SettingsProperty property in Properties)
            {
                if (
                    property.PropertyType.GetCustomAttributes(
                        typeof(SettingsProviderAttribute),
                        false
                    ).Length == 0
                 )
                 {
                     property.Provider = provider;
                 }
             }
         }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

in a ASP.net C# application I have a Checkbox with a custom css. the
We have an ASP.Net application hosted on our network and exposed to a specific
I am storing some web site settings for my ASP.NET website in the application
We are developing a .NET application that uses a few custom controls. One specific
In our Asp.Net Application we have an IHttpHandler handling requests for Images. The Handler
In my ASP.NET application I have separate projects for the Data, Business and UI
My SSRS report fetches data from my DATAWAREHOUSE. The ASP.NET application I have is
I have .NET application that is hosted on IIS 6.1 It is impossible to
I have an ASP.NET application where i have more than 100 pages.In each pages
We have a vb.net application where we have implemented multithreading. We determined that we

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.