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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T12:54:23+00:00 2026-05-13T12:54:23+00:00

I have a class containing the following ConfigurationSection : namespace DummyConsole { class TestingComponentSettings:

  • 0

I have a class containing the following ConfigurationSection:

namespace DummyConsole {
  class TestingComponentSettings: ConfigurationSection {

    [ConfigurationProperty("waitForTimeSeconds", IsRequired=true)]
    [IntegerValidator(MinValue = 1, MaxValue = 100, ExcludeRange = false)]
    public int WaitForTimeSeconds
    {
        get { return (int)this["waitForTimeSeconds"]; }
        set { this["waitForTimeSeconds"] = value; }
    }

    [ConfigurationProperty("loginPage", IsRequired = true, IsKey=false)]
    public string LoginPage
    {
        get { return (string)this["loginPage"]; }
        set { this["loginPage"] = value; }
    }
  }
}

I then have the following in my .config file:

<configSections>
  <section name="TestingComponentSettings" 
           type="DummyConsole.TestingComponentSettings, DummyConsole"/>
</configSections>
<TestingComponentSettings waitForTimeSeconds="20" loginPage="myPage" />

When I then attempt to use this configuration section I get the following error:

var Testing = ConfigurationManager.GetSection("TestingComponentSettings")
             as TestingComponentSettings;

ConfigurationErrorsException was unhandled

The value for the property ‘waitForTimeSeconds’ is not valid. The error is: The value must be inside the range 1-100.

If I change the IntegerValidator to have an ExcludeRage = true, I (obviously) get:

ConfigurationErrorsException was unhandled

The value for the property ‘waitForTimeSeconds’ is not valid. The error is: The value must not be in the range 1-100

If I then change the value of the property in the .config to a number higher than 100, it works.

If I change the validator to just have a MaxValue of 100 it works, but will also accept a value of -1.

Is it possible to use the IntegerValidatorAttribute with a range like this?

Edit to add

Confirmed as an issue by Microsoft.

  • 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-13T12:54:24+00:00Added an answer on May 13, 2026 at 12:54 pm

    As Skrud points out, MS have updated the connect issue:

    The reported issue is because of a quirk in how the configuration system handles validators. Each numeric configuration property has a default value – even if one is not specified. When a default is not specified the value 0 is used. In this example the configuration property ends up with a default value that is not in the valid range specified by the integer validator. As a result configuration parsing always fails.

    To fix this, change the configuration property definition to include a default value that is within the range of 1 to 100:

    [ConfigurationProperty("waitForTimeSeconds", IsRequired=true, 
                           DefaultValue="10")]
    

    This does mean that the property will have a default, but I don’t actually see that as a major issue – we’re saying that it should have a value that falls within a “sensible” range, and should be prepared to set a sensible default.

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

Sidebar

Related Questions

I have a list containing the following structure. class CompareDesignGroup { string FieldId; string
I currently have a class containing the following properties public class Chromosome { public
In my partial class containing the DataSet event I have the following: protected override
I have native C++ class SrcClass containing the following: std::vector<shotEntry> objectsQueue; bool getRelatedEntry(const entryToProcess
I have a class containing a collection of items. For convenience I've provided GetCurrentItem
I have a class containing Linq To SQL objects that are used to populate
I have a class containing several properties (all are strings if it makes any
I have a class library containing several structures each consisting of several value and
I have an example class containing two data points: public enum Sort { First,
I have a class A containing two pointers to objects of another class B.

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.