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

  • Home
  • SEARCH
  • 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 8293911
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T14:00:00+00:00 2026-06-08T14:00:00+00:00

Is there way to write some ConfigurationValidatorAttribute or in some other way that will

  • 0

Is there way to write some ConfigurationValidatorAttribute or in some other way that will allow either both Prop1 and Prop2 are present or none of them?

EDITED

In the following config file when I’ll try to get Domains I want to get runtime exception because domain3 element must have both Prop1 and Prop2 or none of them, but not only one of them!

Just like IsRequired is checked in runtime and throws error if the element doesn’t has Name attribute.

<MySection>
        <Domains>
          <Domain Name="domain1" Prop1="1" Prop2="4" /> 
          <Domain Name="domain2" /> 
          <Domain Name="domain3" Prop1="1" /> 
        </Domains>         
    </MySection>

public class ConfigElement : ConfigurationElement
{     
    [ConfigurationProperty("Name", IsRequired = true)]
    public string Name
    {
        get { return (string)this["Name"]; }
        set { this["Name"] = value; }
    }        

    [ConfigurationProperty("Prop1")]
    public int Prop1
    {
        get { return (int)this["Prop1"]; }
        set { this["Prop1"] = value; }
    }

    [ConfigurationProperty("Prop2")]
    public int Prop2
    {
        get { return (int)this["Prop2"]; }
        set { this["Prop2"] = value; }
    }
}
  • 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-08T14:00:01+00:00Added an answer on June 8, 2026 at 2:00 pm

    Override the PostDeserialize of ConfigurationElement in your ConfigElement Class

     protected override void PostDeserialize()
            {
                base.PostDeserialize();
                //Do what you want
            }
    

    There is a good example on this blog post.

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

Sidebar

Related Questions

Is there a way to write some code that can 'talk' to printer in
Is there some way to write a function f :: (a -> b ->
Is there some way I can catch when a method generates a write to
Is there any standard way of implementing some sort of a write-through buffer for
Here's an interesting problem. Is there a way to write some code using LINQ
Is there any way to write some html (as you might in a block),
Is there a way to write a query like: select * from <some number
Is there a way to write something like this with Mojo::UserAgent ,having the possibility
Is there a way to write a single LINQ expression to get the same
Is there any way to write to a text file in Flex 4.6? Its

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.