How to make WCF client use the same data types as

2019-03-02 09:47发布

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.

1条回答
ゆ 、 Hurt°
2楼-- · 2019-03-02 10:05

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

查看更多
登录 后发表回答