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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T16:26:55+00:00 2026-05-17T16:26:55+00:00

I have a class library that contains my object model. I’d like each object

  • 0

I have a class library that contains my object model. I’d like each object to have data annotations to place validation rules into my model so that validation can be shared across 2 apps. One is an MVC 2 app and the other is a Windows forms app.

I need to be able to validate the object model manually from code using the data annotations, but without using xVal. When I switch the object model library to the 4.0 client profile it can no longer build with the xVal components. The domain object class library will be distributed with the windows app, so I wanted to utilize the 4.0 client profile.

Any ideas?

  • 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-17T16:26:56+00:00Added an answer on May 17, 2026 at 4:26 pm

    Well, I’ll provide an answer with a little more substance in case it might be of help to someone else.

    For our validation, we use a simple Validate method like this:

    public void Validate(T entity)
    {
        var context = new ValidationContext(entity, null, null);
        var results = new List<ValidationResult>();
    
        bool valid = Validator.TryValidateObject(entity, context, results, true);
    
        if (!valid)
            ; // do something fancy with the results here, perhaps
    }
    

    You can also skip the TryValidateObject and go right to ValidateObject if you don’t want to do anything fancy with the results.

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

Sidebar

Related Questions

Wondering if this is possible. We have an 3rd Party library that contains identification
I have a WPF dll that contains a number of Window classes and exposes
I'm working on creating a Javascript Tab library. Actually, it's already been developed and
I have a .NET solution containing two projects: An ASP.NET MVC project, 'Website' A
I'm implementing a face tracker on Android, and as a literature study, would like
I have the following problem. I have two classes, in this case A and
I must be really stupid, but I'm at my wits' end with a JPA
My project is split up into a typical 3 layer structure for a Silverlight
I recently started working with Silverlight and immediately noticed the difference between the Silverlight
Let me give a scenario then see if anyone has a solution / work-around.

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.