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.
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?
There's no code between this two actions. DataContract mark workes fine, everything's ok. Any suggestions on this issue?
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?
Maybe the answer is simple, but I can't figure it out.
Thank You.
<DataContract()>
Public Class Customer
Private Type_of_clientField As Integer = -1
<DataMember(Order:=1)>
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
开发者_运维技巧 <ServiceContract(SessionMode:=SessionMode.Allowed)>
<DataContractFormat()>
Public Interface CustomerService
<OperationContract()>
Function addCustomer(ByRef customer As Customer) As Long
End Interface
type_of_client properties value is 6 before I call addCustomer function. After it enters that function the value is 0.
UPDATE: The issue is in instance creating.
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.
What's is the difference? Could that be serialization issue?
If you're using the order parameter of datamember must start at 0 and increment (i.e. make 1 into 0, the next datamember becomes 1, etc). This might work if you had more than one member, however it has nowhere to put your variable as there is no 1 position for the class you show.
精彩评论