Note that there are some explanatory texts on larger screens.

plurals
  1. PODataContract Known Types - passing array
    primarykey
    data
    text
    <p>Im having problems when passing an generic List, trough a WCF operation. In this case, there is a List of int. The example 4 is described <a href="http://msdn.microsoft.com/en-us/library/ms730167%28v=VS.90%29.aspx" rel="nofollow noreferrer">here in MSDN</a>. Note that in MSDN sample, is described: </p> <blockquote> <p>// This will serialize and deserialize successfully because the generic List is equivalent to int[], which was added to known types.</p> </blockquote> <p>Above, is the DataContract:</p> <pre><code> [DataContract] [KnownType(typeof(int[]))] [KnownType(typeof(object[]))] public class AccountData { [DataMember] public object accNumber1; [DataMember] public object accNumber2; [DataMember] public object accNumber3; [DataMember] public object accNumber4; } </code></pre> <p>In client side, Im calling the operation like this:</p> <pre><code>DataTransfer.Service.AccountData data = new DataTransfer.Service.AccountData() { accNumber1 = 100, accNumber2 = new int[100], accNumber3 = new List&lt;int&gt;(), accNumber4 = new ArrayList() }; cService.AddAccounts(data); </code></pre> <p>Also, here is the decorations of the generated AccountData obj (WCF proxy):</p> <pre><code>[System.Diagnostics.DebuggerStepThroughAttribute()] [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Runtime.Serialization", "3.0.0.0")] [System.Runtime.Serialization.DataContractAttribute(Name="AccountData", Namespace="http://schemas.datacontract.org/2004/07/DataTransfer.Service")] [System.SerializableAttribute()] [System.Runtime.Serialization.KnownTypeAttribute(typeof(DataTransfer.Client.CustomerServiceReference.PurchaseOrder))] [System.Runtime.Serialization.KnownTypeAttribute(typeof(DataTransfer.Client.CustomerServiceReference.Customer))] [System.Runtime.Serialization.KnownTypeAttribute(typeof(int[]))] [System.Runtime.Serialization.KnownTypeAttribute(typeof(object[]))] </code></pre> <p>The exception is: </p> <blockquote> <p>There was an error while trying to serialize parameter <a href="http://tempuri.org/:myEntity" rel="nofollow noreferrer">http://tempuri.org/:myEntity</a>. The InnerException message was 'Type Generic List' with data contract name 'ArrayOfint:<a href="http://schemas.microsoft.com/2003/10/Serialization/Arrays" rel="nofollow noreferrer">http://schemas.microsoft.com/2003/10/Serialization/Arrays</a>' is not expected. Add any types not known statically to the list of known types</p> </blockquote>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload