locked
[DataMember(Name = "ProjectID", IsRequired = true, EmitDefaultValue = false)] Not working ?? RRS feed

  • Question

  • Hi friends , [DataMember(Name = "ProjectID", IsRequired = true, EmitDefaultValue = false)] is not working in silverlight .. what can i add to makes this work .. Thanks
    Wednesday, November 4, 2009 1:34 AM

Answers

  • Hi Bobby,

      It seems that the Required attribute is not working like this.  Here is a quotation from msdn document you can have a look.

      Although the IsRequired property is set to true, the incoming data may be null or zero, and a type must be prepared to handle this possibility. Do not use IsRequired as a security mechanism to protect against bad incoming data.

     The document is here :   http://msdn.microsoft.com/en-us/library/ms731138.aspx

      It means required attribute is used to prevent a missing of data.

    Best Regards

     

    Friday, November 6, 2009 3:40 AM

All replies

  • Hello,

    "not working" means getting some errors? or not showing in intellsense? DataMember is under System.Runtime.Serialization. If you are getting error then please let us know the details (like the code that you wrote, what you expect and what you are getting. and etc..)

    Wednesday, November 4, 2009 9:41 AM
  •  if i pass null value to property it doesn't throw error ... i'm using basicHttpBinding (wcf service )

    Wednesday, November 4, 2009 11:19 AM
  • Hi Bobby,

      It seems that the Required attribute is not working like this.  Here is a quotation from msdn document you can have a look.

      Although the IsRequired property is set to true, the incoming data may be null or zero, and a type must be prepared to handle this possibility. Do not use IsRequired as a security mechanism to protect against bad incoming data.

     The document is here :   http://msdn.microsoft.com/en-us/library/ms731138.aspx

      It means required attribute is used to prevent a missing of data.

    Best Regards

     

    Friday, November 6, 2009 3:40 AM