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

回眸只為那壹抹淺笑 提交于 2019-12-20 04:28:09

问题


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:


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



来源:https://stackoverflow.com/questions/2309969/how-to-make-wcf-client-use-the-same-data-types-as-the-wcf-service

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!