none
NetDataContract and svcutil

    Question

  • Hi,

    I'm trying to use the NetDataContract attribute (code taken from aaron's site) and have svcutil generate the stubs for me but am still unable to get the client to serialize my object correctly.  In fact, I don't see a ref to NetDataContract in the proxy code at all and even when I manually add it, it still doesn't work.  Is it possible to use svcutil with the NetDataContract attribute?  If so, is there a special parameter one must use?

    TIA
    Thursday, January 24, 2008 8:44 PM

Answers

  • SvcUtil does not support NetDataContract based services.   You will either need to use the same types on both sides explicitly (which is essentially what you're doing anyway).  

     

    Saturday, January 26, 2008 12:47 AM

All replies

  • You cannot use svcutil for services using the NetDataContractSerializer. If you are attempting to use the NetDataContractSerializer, you need to be working in a shared library environment (the same library is shipped to both client and host).
    Thursday, January 24, 2008 11:48 PM
  • Eric, is this documented somewhere?  I ask because this msg:  http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=1325936&SiteID=1 refers to "generated" code that, to me, implies svcutil.

    Thanks.
    Friday, January 25, 2008 1:11 AM
  • This blog also mentions it but doesn't offer any details.  Can someone from msft comment?

    http://howevangotburned.wordpress.com/2007/12/06/type-fidelity-across-the-wire-in-wcf/

    "If you use the handy [NetDataContract] attribute, you have to mark it as such on both the service interface and the client interface, which means you need to hand-modify the generated client code."



    Friday, January 25, 2008 12:25 PM
  • SvcUtil does not support NetDataContract based services.   You will either need to use the same types on both sides explicitly (which is essentially what you're doing anyway).  

     

    Saturday, January 26, 2008 12:47 AM
  • Hi Martin,
    Is there any way around this ?
    I've added this code (below)  to the client - but it gives me trouble.

    The problem is that using nHibernate forces me to use svcutils, and Circular reference in the object model - make DataContractSerializer uselesss, so I have to use the NetDataContract.

    So, I'm stuck.....

    Thanks,
    Dani



    -----------------
    Client code to make the client know about the NetDataContract Serializer:)

        foreach (OperationDescription desc in channelFactory.Endpoint.Contract.Operations)
          {
            DataContractSerializerOperationBehavior dcsOperationBehavior = desc.Behaviors.Find<DataContractSerializerOperationBehavior>();
            if (dcsOperationBehavior != null)
            {
              int idx = desc.Behaviors.IndexOf(dcsOperationBehavior);
              desc.Behaviors.Remove(dcsOperationBehavior);
              desc.Behaviors.Insert(idx, new NetDataContractOperationBehavior(desc));
      
            }
          }
    Dani
    Thursday, October 15, 2009 4:29 PM