Note that there are some explanatory texts on larger screens.

plurals
  1. POCreating instance of a service-side DataContract class on client-side in WCF
    text
    copied!<p>I have my custom class Customer with its properties. I added DataContract mark above the class and DataMember to properties and it was working fine, but I'm calling a service class's function, passing customer instance as parameter and some of my properties get 0 values.</p> <p>While debugging I can see my properties values and after it gets to the function, some properties' values are 0. Why it can be so? </p> <p>There's no code between this two actions. DataContract mark workes fine, everything's ok. Any suggestions on this issue? </p> <p>I tried to change ByRef to ByVal, but it doesn't change anything. Why it would pass other values right and some of integer types just 0?</p> <p>Maybe the answer is simple, but I can't figure it out. </p> <p>Thank You.</p> <pre><code> &lt;DataContract()&gt; Public Class Customer Private Type_of_clientField As Integer = -1 &lt;DataMember(Order:=1)&gt; Public Property type_of_client() As Integer Get Return Type_of_clientField End Get Set(ByVal value As Integer) Type_of_clientField = value End Set End Property End Class &lt;ServiceContract(SessionMode:=SessionMode.Allowed)&gt; &lt;DataContractFormat()&gt; Public Interface CustomerService &lt;OperationContract()&gt; Function addCustomer(ByRef customer As Customer) As Long End Interface </code></pre> <p>type_of_client properties value is 6 before I call addCustomer function. After it enters that function the value is 0.</p> <p><strong>UPDATE:</strong> The issue is in instance creating. </p> <p>When I create an instance of a class on client side, that is stored on service side, some of my properties pass 0 or nothing, but when I call a function of a service class, that returns a new instance of that class, it works fine. </p> <p>What's is the difference? Could that be serialization issue? </p>
 

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