![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
| |
| | #1 (permalink) |
| | Deserialize array as object Hello Newsgroup, I have trouble serializing a data contract that has a data member of type object. At runtime this member carries an array of strings and WCF fails to deserialize this member: Code: [DataContract] public class DC { private object _dcvalue; public DC () {} public DC (object v ) { _dcvalue = v; } [DataMember] public object DCValue { get { return _dcvalue; } set { _dcvalue = value; } } } The WCF Error Trace reads as follows: Type 'System.String[]' with data contract name 'ArrayOfstring:http:// schemas.microsoft.com/2003/10/Serialization/Arrays' is not expected. Add any types not known statically to the list of known types - for example, by using the KnownTypeAttribute attribute or by adding them to the list of known types passed to DataContractSerializer. How do I transfer array types in data members of type objects? Thanks in advance for your help! Sebastian Dau. |
My System Specs![]() |
| | #2 (permalink) |
| | RE: Deserialize array as object You'll want to add the known type attribute: [KnownType(typeof(String[]))] to the DCValue DataMember. "sebastian.dau@xxxxxx" wrote: Quote: > Hello Newsgroup, > > I have trouble serializing a data contract that has a data member of > type object. > At runtime this member carries an array of strings and WCF fails to > deserialize this member: > Code: > [DataContract] > public class DC > { > private object _dcvalue; > > public DC () > {} > > public DC (object v ) > { > _dcvalue = v; > } > > [DataMember] > public object DCValue > { > get { return _dcvalue; } > set { _dcvalue = value; } > } > } > > The WCF Error Trace reads as follows: > Type 'System.String[]' with data contract name 'ArrayOfstring:http:// > schemas.microsoft.com/2003/10/Serialization/Arrays' is not expected. > Add any types not known statically to the list of known types - for > example, by using the KnownTypeAttribute attribute or by adding them > to the list of known types passed to DataContractSerializer. > > How do I transfer array types in data members of type objects? > > Thanks in advance for your help! > > Sebastian Dau. > > |
My System Specs![]() |
| | #3 (permalink) |
| Vista Enterprise x32 | Re: Deserialize array as object I have the same problem. But, setting the attribute [KnownType(typeof(String[]))] on a DataMember does not compile. Error 2 Attribute 'KnownType' is not valid on this declaration type. It is only valid on 'class, struct' declarations. I hope someone have a solution for this issue.... |
My System Specs![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| adding a custom object to array | PowerShell | |||
| Writing an array back in to an AD Object | PowerShell | |||
| array or object??? | PowerShell | |||
| Creating an array of floats using new-object | PowerShell | |||