Note that there are some explanatory texts on larger screens.

plurals
  1. POMonotouch 6.0.2: Why cannot serialize the object when using WCF services
    primarykey
    data
    text
    <p>I use the WCF with BasicHttpBinding in monotouch(6.0.2) to consume the .net WCF Service, I pass 3 parameters which the type is int,int, DishOrder(user-defined type), in the server site, it can read the int parameters correctly, but the user-defined object(dishOrder) is always null, why?</p> <p>I have already used the [DataContract] attribute mark in the user-defined type class.</p> <p>in monotouch (client side code:)</p> <pre><code>[DataContract] public class DishOrder2 { [DataMember] public int BillID { get; set; } [DataMember] public int TableID { get; set; } } public partial interface IMenuContract { [OperationContract] int OpenTable(int tableID, int lastVerNo,DishOrder2 order); } public partial class MyServiceClient : ClientBase&lt;IMenuContract&gt;,IMenuContract { public int OpenTable(int tableID, int lastVerNo,DishOrder2 order) { return Channel.OpenTable(tableID,lastVerNo,order); } private partial class FDMenuServiceClientChannel { public int OpenTable(int tableID, int lastVerNo,DishOrder2 order) { object[] _args = new object[3]; _args[0]=tableID; _args[1]=lastVerNo; _args[2]=order; return (int)base.Invoke("OpenTable", _args); } } } //end of public partial class FDMenuServiceClient pulic void CallServiceTest() { using (MyServiceClient.serviceClient = MyServiceClient.CreateServiceClient ()) { DishOrder2 test=new DishOrder2(); test.BillID=123; test.TableID=456; serviceClient.OpenTable(111,222,test); } } </code></pre> <p>in service site(.net 3.5) code:</p> <pre><code>[DataContract] public class DishOrder2 { [DataMember] public int BillID { get; set; } [DataMember] public int TableID { get; set; } } [OperationContract] int OpenTable(int tableID, int lastVerNo,DishOrder2 order); public int OpenTable(int tableID, int lastVerNo,DishOrder2 dishOrder) //service implementation { try { //**---why the object:dishorder is null?** throw the nullref exception if (dishOrder.BillID&gt;0) ... //**tableID &amp; lastVerNo is read OK 111,222** ... } catch (Exception ex) { throw FaultException... } } </code></pre>
    singulars
    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.
    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