简体   繁体   中英

Unable to use Validator class belongs to System.ComponentModel.DataAnnotations namespace in WPF

I'm unable to use Validator class belongs to System.ComponentModel.DataAnnotations namespace in WPF. Don't know whether Validator class is shipped with that DLL or not. I'm using .NET 4.5 Framework. As per Microsoft release notes Validator class can be used from .NET 4.0 version and I'm using higher version that that.

I know something silly is getting missed. Any help would be highly appreciated.

The simplest answer to this question is to add System.ComponentModel.DataAnnotations DLL as a reference to your project.

Now that's surprise me. The using statement (using System.ComponentModel.DataAnnotations;) didn't throw any error even there is no reference of System.ComponentModel.DataAnnotations DLL added in the project. But the only problem was that Validator class was not available.

The moment I added DLL, I'm able to use Validator class. Shouldn't it be an error before only when I used Using statement without adding DLL? Or, is it a known bug? Or, am I missing something again?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM