Results 1 to 6 of 6

Thread: WCF: Dataset Parameter to OperationContract

  1. #1
    solomoum is offline VB.NET Forum Newbie
    .NET Framework
    .NET 3.0 (VS 2005/2008)
    Join Date
    Feb 2009
    Posts
    3
    Reputation
    0

    Angry WCF: Dataset Parameter to OperationContract

    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.CustomersDatase t))> _
    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 by solomoum; 03-24-2009 at 5:45 AM.

  2. #2
    petersgyoung is offline VB.NET Forum Enthusiast
    .NET Framework
    .NET 3.0 (VS 2005/2008)
    Join Date
    Mar 2008
    Location
    Hong Kong
    Posts
    40
    Reputation
    110
    Do not use ByRef in your OperationContract.

  3. #3
    solomoum is offline VB.NET Forum Newbie
    .NET Framework
    .NET 3.0 (VS 2005/2008)
    Join Date
    Feb 2009
    Posts
    3
    Reputation
    0
    Quote Originally Posted by petersgyoung View Post
    Do not use ByRef in your OperationContract.
    Thanks, but i have already tried this. The same error...

    I use VS2008 SP1 and XP SP3, just in case that it's important.
    Last edited by solomoum; 03-24-2009 at 4:51 AM.

  4. #4
    petersgyoung is offline VB.NET Forum Enthusiast
    .NET Framework
    .NET 3.0 (VS 2005/2008)
    Join Date
    Mar 2008
    Location
    Hong Kong
    Posts
    40
    Reputation
    110
    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.

  5. #5
    solomoum is offline VB.NET Forum Newbie
    .NET Framework
    .NET 3.0 (VS 2005/2008)
    Join Date
    Feb 2009
    Posts
    3
    Reputation
    0
    Quote Originally Posted by petersgyoung View Post
    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.

  6. #6
    mrpraveen is offline VB.NET Forum Newbie
    .NET Framework
    .NET 3.5
    Join Date
    Sep 2010
    Posts
    1
    Reputation
    0

    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

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •