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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T08:07:20+00:00 2026-06-18T08:07:20+00:00

We are working on a legacy C# enterprise app. Its client uses several web

  • 0

We are working on a legacy C# enterprise app. Its client uses several web services, whose URLs, among lots of other settings, are read from the local app.config file. We want to migrate these settings into a global DB to simplify their management. However, I can’t figure out how (and whether) it is possible to migrate the web service URLs. These are read from the service client code generated by VS and I can’t seem to find a way to tell VS to use a different settings provider than the one generated into Settings.Designer.cs .

We can overwrite the service facade’s Url property with the value we want, after it is created – this is the solution currently used in several places in the code. However, I wouldn’t like to touch every part of our codebase where any of these services is used (now and in the future). Even less would I like to modify generated code.

There has to be a better, cleaner, safer solution – or is there?

Btw our app runs on .NET 2.0 and we won’t migrate to newer versions of the platform in the foreseeable future.

  • 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-18T08:07:21+00:00Added an answer on June 18, 2026 at 8:07 am

    The Refernce.cs file that is generated by the Visual Studio indicates that the URL of the webservice will be retrieved from the settings:

    this.Url = global::ConsoleApplication1.Properties.
        Settings.Default.ConsoleApplication1_net_webservicex_www_BarCode;
    

    I believe that John Saunders gave you a wonderful suggestion in his comment. You need a SettingsProvider class which:

    …defines the mechanism for storing configuration data used in the
    application settings architecture. The .NET Framework contains a
    single default settings provider, LocalFileSettingsProvider, which
    stores configuration data to the local file system. However, you can
    create alternate storage mechanisms by deriving from the abstract
    SettingsProvider class. The provider that a wrapper class uses is
    determined by decorating the wrapper class with the
    SettingsProviderAttribute. If this attribute is not provided, the
    default, LocalFileSettingsProvider, is used.

    I don’t know how much you have progressed following this approach, but it should go pretty straighforward:

    1. Create the SettingsProvider class:

      namespace MySettings.Providers
      {
          Dictionary<string, object> _mySettings;
      
          class MySettingsProvider : SettingsProvider
          {
              // Implement the constructor, override Name, Initialize, 
              // ApplicationName, SetPropertyValues and GetPropertyValues (see step 3 below)
              // 
              // In the constructor, you probably might want to initialize the _mySettings 
              // dictionary and load the custom configuration into it.
              // Probably you don't want make calls to the database each time
              // you want to read a setting's value
          }
      }
      
    2. Extend the class definition for the project’s YourProjectName.Properties.Settings partial class and decorate it with the SettingsProviderAttribute:

      [System.Configuration.SettingsProvider(typeof(MySettings.Providers.MySettingsProvider))]
      internal sealed partial class Settings
      {
          //
      }
      
    3. In the overridden GetPropertyValues method, you have to get the mapped value from the _mySettings dictionary:

      public override SettingsPropertyValueCollection GetPropertyValues(
          SettingsContext context,
          SettingsPropertyCollection collection)
      {
          var spvc = new SettingsPropertyValueCollection();
          foreach (SettingsProperty item in collection)
          {
              var sp = new SettingsProperty(item);
              var spv = new SettingsPropertyValue(item);
              spv.SerializedValue = _mySettings[item.Name];
              spv.PropertyValue = _mySettings[item.Name];
              spvc.Add(spv);
          }
          return spvc;
      }
      

    As you can see in the code, in order to do that, you need to know the setting name as it was added in the app.config and the Settings.settings when you have added the reference to the web service (ConsoleApplication1_net_webservicex_www_BarCode):

    <applicationSettings>
        <ConsoleApplication30.Properties.Settings>
            <setting name="ConsoleApplication1_net_webservicex_www_BarCode"
                serializeAs="String">
                <value>http://www.webservicex.net/genericbarcode.asmx</value>
            </setting>
        </ConsoleApplication30.Properties.Settings>
    </applicationSettings>
    

    This is a very simple example, but you might use a more complex object to store the configuration information in conjunction with other properties available in the context such as item.Attributes or context in order to get the proper configuration value.

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

Sidebar

Related Questions

i am working on a legacy enterprise database that uses multiple columns to retrieve
I am working a legacy web service app which we has now changed, so
I am working on a legacy Java Enterprise server project, trying to set up
I am working on a legacy app in VB6 and am wondering what the
I'm working on a legacy system that has uses stored procs, business objects and
I'm working on a legacy where some fields uses special encodings. Is it somehow
I'm working a legacy VC++6 app that is trying to add in unicode support,
I am working on a legacy application that contains references to two .asmx web
I'm working with legacy code that uses some convoluted logic to bind IN and
We are working with a legacy database that uses SQL server uniqueidentifier columns for

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.