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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T17:48:46+00:00 2026-06-06T17:48:46+00:00

I was trying to implement custom validation attribute by inheriting from ValidationAttribute and found

  • 0

I was trying to implement custom validation attribute by inheriting from ValidationAttribute and found strange thing.
My custom attribute requires validation context, so I’ve looked at the R# decompiled source of ValidationAttribute and saw, that I need override this in my custom attribute class:

public virtual bool RequiresValidationContext
{
  get
  {
    return false;
  }
}

Now the fun part – Visual Studio 2012 does not let me do that, telling me that there’s no such property for override, although when running project, in debug view I can see that property.

Interesting thing is, that in reference path I see:

C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETFramework\v4.0\System.ComponentModel.DataAnnotations.dll

But in R# decompiled file is different path:

Assembly location: C:\Windows\Microsoft.NET\Framework\v4.0.30319\System.ComponentModel.DataAnnotations.dll

So, compiler uses different dll from runtime.
So, I’ve tried to switch reference dll to the one R# decompiles, but looks like VS2012 is replacing it with it’s version anyway, in project file it looks like:

<Reference Include="System.ComponentModel.DataAnnotations" />

So, no path is saved in project.
Is there any solution to this without manual editing of a project?

Btw, with 4.5 NET it works fine, I mean it sees RequiresValidationContext property as supposed.

Update: As they say, picture is worth thousand words:

enter image description here

  • 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-06T17:48:47+00:00Added an answer on June 6, 2026 at 5:48 pm

    The solution is simple the property RequiresValidationContext was added to ValidationAttribute in .NET 4.5. Since you are coding/using/developing with C# 4.0, i suspect that you target .NET Framework 4.0 and in that version the property does not exist.

    So you can´t override the property, cause it does not exist.

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

Sidebar

Related Questions

I am trying to implement custom attribute validation, similar to one demonstrated here in
I'm trying to implement a custom validation annotation in Seam. We have a list
I'm trying to implement my custom authorize attribute like: public class MyCustomAuth : AuthorizeAttribute
I am trying to implement a crossfield validation (JSR-303) with a custom annotation on
I'm trying to implement my custom security attribute. It's very simple for now [Serializable]
I'm trying to implement a custom class for dataannotations that retrieves error messages from
I am trying to implement a custom Java widget using GWT.This requires me to
I am trying to implement a custom Java widget using GWT.This requires me to
I'm trying to implement client validation for my custom type, however i'm not sure
im trying to implement a custom error page, what i want to be able

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.