Why can't I reference System.ComponentModel.DataAnnotations?

后端 未结 14 1690
遥遥无期
遥遥无期 2020-11-28 08:47

I\'m trying to use DataAnnotations in my WPF project to specify a maximum length of strings, with the following:

using System.ComponentModel.DataAnnotations;         


        
14条回答
  •  执念已碎
    2020-11-28 09:23

    I found that I cannot reference System.ComponentModel.DataAnnotations from Silverlight 5 with the below version at (1). I found that Silverlight 5 assemblies cannot use .NET assemblies, it gives the error "You can't add a reference to System.ComponentModel.DataAnnotations as it was not built against the Silverlight runtime. ..." I plan to workaround this by hopefully installing the Silverlight 5 package found at (2) below. If this fails I will update this post.

    [UPDATE: it failed. I installed everything relating to Silverlight 5 and I don't have the Silverlight version of the .dll assembly System.ComponentModel.DataAnnotations . Too bad. UPDATE II: I found an old .dll having this name from a previous installation of Silverlight developer's kit for Visual Studio 2008 or 2010. I added this file and it seems to 'work', in that IntelliSense is now recognizing attributes on class members, such as [Display(Name = "My Property Name")]. Whether or not this works for everything else in this .dll I don't know.]

    (1)

    Microsoft Visual Studio Professional 2013
    Version 12.0.21005.1 REL
    Microsoft .NET Framework
    Version 4.5.51641
    

    Installed Version: Professional

    (2) http://go.microsoft.com/fwlink/?LinkId=229318

提交回复
热议问题