I am having problems while crossing a generic list, open the WCF operation. In this case, there is a list of int, as described in Example 4 Note that in the MSDN sample, is described:
// This will be successfully sorted and deserialize because the general list int [] equals , Which was added to known types. [Type Typef (item [])] Public class account data {{Data type ] Public Objects ANNumber 1; [Database] Public Object ACC number 2; [Datamember] Public Object ACC number 3; [Database] Public Object ACC 4; }
In the client side, I am calling the operation like this:
DataTransfer.Service.AccountData data = new data transfer.Service.AccountData () {AccNumber1 = 100, ANM 2 = new int [100], ANCNumber3 = new list & lt; Int & gt; (), ACNumber 4 = new Arrayist ()}; CService.AddAccounts (data); In addition, the account generated here is the decoration of obj (WCF proxy):
[System.Diagnostics.DebuggerStepThroughAttribute ()] [System.CodeDom. Compiler.GeneratedCodeAttribute ("System.Runtime.Serialization", "3.0.0.0") [System.Runtime.Serialization.DataContractAttribute (name = "account data", namespace = "http://schemas.datacontract.org/2004/ 07 / DataTransfer.Service ")] [System.SerializableAttribute ()] [System.Runtime.Serialization.KnownTypeAttribute (typeof (DataTransfer.Client.CustomerServiceReference.PurchaseOrder)) [system. From time to time. Serialization. . [Customer service service. Customer]] [System.Runtime.Serialization.KnownTypeAttribute (typeof (int [])] [System.Runtime.Serialization.KnownTypeAttribute (typeof (object [])]
exception :
There was an error while trying to serial the parameter. The innerAxception message was 'contract generative list', in which data contract name 'arrayoffinant' is not required.
If you type your declaration type, then the serialization works fine:
[DataContract] Public class account data {[Database] Public Item accNumber1 {get; Set;} [datamember] public int [] ANM 2 {Received; Set; } [Datamember] public list & lt; Int & gt; AccNumber3 {Receive; Set; } [Database] Public Aurelit ANNM 4 {Received; Set up;}}
(I recommend using properties instead of public fields.)
Do you really need the type of object to your fields is? If the above classes are very restrictive then there are ways to make it more flexible, but not as flexible as you want
Also keep in mind that the known type
attribute is the whole class Applies to and not personal property.
Comments
Post a Comment