开发者

How to make WCF client use the same data types as the WCF service

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:\Pr开发者_运维技巧oxy.cs /config:\App.config

Thanks again.


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜