Question WCF: Dataset Parameter to OperationContract

solomoum

New member
Joined
Feb 17, 2009
Messages
3
Programming Experience
Beginner
Hello everybody!
I'm using VS2008 and I'm new with WCF. I have the following problem:

I have a function in the IService:
" <OperationContract()> _
Function SaveData(ByRef BaseDS As DataSet) As Boolean"

In my Client, i want to call the Function with a Typed Dataset,
for example:
"Dim changes = CType(Me.CustomersDataSet.GetChanges, DataSet)
If changes IsNot Nothing Then
Using proxy As New BaseDataServices.BaseDataServiceClient
proxy.SaveData(changes)
End Using
End If"

But i recieve the following Error:
"Was presented a fault at the effort of serielizing parameter http://tempuri.org/:BaseDS. Was the message of InnerException isn't expected type 'Entities.BaseDataSet' with name of convention of given 'BaseDataSet: http://schemas.datacontract.org/2004/07/Entities'. Add any types that are not statically acquaintance in the list with the known types - as an example, using characteristic KnownTypeAttribute or adding are transmitted to them in the list with the known types that in the DataContractSerializer.'. See InnerException for more details."
Note:This message is translated from Greek.

I have no DataContract.

I tried the following :
" <OperationContract()> _
<ServiceKnownType(GetType(System.Data.Dataset))> _
<ServiceKnownType(GetType(Entities.CustomersDataset))> _
Function SaveData(ByRef BaseDS As DataSet) As Boolean"

I steel recieve the same Error.

What can i do to solve this?

Sorry for my English....
And thanks in andvanced!
 
Last edited:
I cannot help you to solve your problem. I can just tell you some obvious mistake that I found. Although Dataset (also DataTable) is serializable, it is not very useful for complicated scenario. You should not rely on automatic schema generation. The best practice is to create a DataType using DataContract. If you want to send a set of data, transfer them as a Generic List.
 
I cannot help you to solve your problem. I can just tell you some obvious mistake that I found. Although Dataset (also DataTable) is serializable, it is not very useful for complicated scenario. You should not rely on automatic schema generation. The best practice is to create a DataType using DataContract. If you want to send a set of data, transfer them as a Generic List.

Thank you, but i allready solved this.
The problem was in my client IService implementation : The code were generated by the wizard not include the KnownTypeAttribute. So i added and all works perfect as far.

Thank you again.
 
help

Please let me know how to return dataset from an operation contract after filling it from database and how to consume it from client
 
Back
Top