Silverlight serialization of a .NET Web service causes XML error -
This class is provided by a web service which is then consumed by a Silverlight app (I do not know Whether it is relevant or not)
[serialable] public class entry {private string _ title; Public string id {get; Set; } Public string title {get {return _title; } Set {_title = value; }} Public string links {get; Set; } Public Date Time Published {get; Set; } Public Date Time Update {get; Set; } The public user user {receives; Set; } Public service service {receive; Set; } Public listing & lt; Comment & gt; Comments {get} Set; } Public listing & lt; As & gt; Likes {get; Set; } Public listing & lt; Media & gt; media get; Set; }} _title variable I'll show what's going wrong. When I refer to the web service in my Silverlight app, then forwarding XSD:
& lt; Xs: complex type name = "entry" & gt; & Lt; XS: Sequence & gt; & Lt; Xs: element name = "_ title" nile = "true" type = "x: string" /> & Lt; Xs: element name = "_x003C_Comments_x003E_k__ backingfield" Nilibble = "true" type = "TNS: commentary of Arrayoff" /> & Lt; Xs: element name = "_x003C_Id_x003E_k__ backingfield" nilibble = "true" type = "x: string" /> & Lt; Xs: element name = "_x003C_Likes_x003E_k__ backingfield" Nilibal = "true" type = "TNS: arrayoff like" /> & Lt; Xs: element name = "_x003C_Link_x003E_k__ backingfield" Nilibble = "true" type = "x: string" /> & Lt; Xs: element name = "_x003C_Media_x003E_k__ backingfield" Nilibal = "true" type = "TNS: Arrayoff media" /> & Lt; Xs: element name = "_x003C_Published_x003E_k__ backfying" type = "x: datetime" /> & Lt; Xs: element name = "_ x003C_Service_x003E_k__ backfield" Nibil = "true" type = "TNS: service" /> & Lt; Xs: element name = "_x003C_Updated_x003E_k__ backfoldfield" type = "x: datetime" /> & Lt; Xs: element name = "_x003C_User_x003E_k__ backingfield" Nibil = "true" type = "TNS: user" /> & Lt; / XS: sequence & gt; & Lt; / XS: complexType & gt; Note that the property of the title is only given the name, others have the & lt; Link & gt; _BackingField is named, when you try and load the element because you do not have & lt; Or> on the name of a property.
Why is it serializing the banking field and not public property?
serializable attribute in the
DataContractSerializer (The default serializer for WCF), the behavior is that all fields are public and private, because the backing fields are auto-generated in your case, the compiler comes with a strange name, on which you Conflict with any field name to be created There is no possibility of (C # can not be accepted by the "& lt;" or ">" in the identifier, but CLR is not such a pick.) Perhaps the most to improve this situation The easy way DataContract and DataMember to the entry class as appropriate.
Comments
Post a Comment