Reputation: 13302
Up until now I've been implementing WCF services out of the box by letting Visual Studio take care of generating all of the client-side proxy code. But to prevent some maintenance nightmares, I now need to share DataContracts between different services on the client side. So I've moved the DataContracts for my services into their own assembly so that I can generate a client-side assembly containing the DataContract classes as is demoed here and here.
After generating & referencing the client DataContract assembly and specifying Reuse Types when generating the proxy in Visual Studio, most of the DataContract code was gone from the generated Reference.cs class, except a couple types were left behind:
public partial class OWSResultOfArrayOfguid ...
public partial class OWSResultOfOrderFulfillmentResult ...
These are the return types of a couple service methods that use a DataContract with a generic type. Here is its declaration:
[DataContract(Name = "OWSResultOf{0}")]
public class OWSResult<T>
After inspecting the .xsd files that I generated using svcutil, OWSResult, of any type, does not appear to be included. Here is the command I used to generate the files:
>svcutil /dconly "C:\...\bin\Debug\OWS.DataContracts.dll"
Where DataContracts.dll is the assembly I moved all of the DataContract definitions into. And in case I'm just not seeing the definition in the .xsd files, here is the command I'm using to generate the C# client code:
>svcutil /dconly /language:C# *.xsd /out:OWS.DataContracts.cs /edb /s /ct:System.Collections.Generic.List`1 /r:C:\windows\Microsoft.NET\Framework\v2.0.50727\mscorlib.dll
So I added a KnownType attribute to my generic DataContract (OWSResult) to tell the tool about these implementations of the type. EG:
[KnownType(typeof(OWSResult<Guid>))][KnownType(typeof(OWSResult<OrderFulfillmentResult>))]
but it still does not generate these types. How can I get svcutil to include these?
Upvotes: 3
Views: 444