views:

175

answers:

2

I have a .NET WCF service that services only .NET WCF clients (all .NET 3.5, no interoperability, via TCP, binary encoding). Using svcutil.exe the composite types that are used by the data members of the service are generated as part of the proxy.cs class used by the clients.

However, what to do if I wanted to reference the same types declared on the server/WCF side? Scenario: three assemblies: client.exe, wcfobjects.dll and wcfservice.dll --> the wcfservice.dll references wcfobjects.dll --> the client too references wcfobjects.dll

How can I generate a proxy that does NOT include the types used by the service? Is that possible? Thanks.

Found this answer: in order for svcutil.exe to NOT generate the types in the client proxy, you need to explicitly reference the wcfobjects.dll at the prompt:

svcutil *.wsdl *.xsd /async /tcv:Version35 /language:C# /r:\wcfobjects.dll /out:\Proxy.cs /config:\App.config

Thanks again.

A: 

You need to edit the proxy class file manually to add the original data types. Define the data types in a separate assembly and include the same on both sides (service and client).

Kangkan
-1: no, you, don't.
John Saunders
You did get one thing right though - define the types in a third assembly that is referenced from both service and client.
slugster
Thanks to John Saunders and slugster. I stay corrected.
Kangkan
+2  A: 

In the "Add Service Reference" dialog, on the "Advanced" tab, specify "Reuse existing types".

John Saunders
What about doing this using svcutil.exe?
John
I'm sure you can do it, I just haven't done it before. `svcutil /?` and go from there.
John Saunders