简体   繁体   English

svcutil.exe excludetypes问题

[英]svcutil.exe excludetypes problem

My service uses a type Foo defined in another DLL, and my client also uses that DLL to get that type. 我的服务使用在另一个DLL中定义的Foo类型,而我的客户端也使用该DLL获取该类型。 Rather than generating a proxy class for that type, I'd like the proxy code to just refer to the real type. 我不想为该类型生成代理类,而是希望代理代码仅引用实际类型。 I can accomplish this manually by generating the proxy with WSDL.EXE on the running service, manually editing out the partial class Foo definition from it, and adding a Using statement. 我可以通过在运行的服务上使用WSDL.EXE生成代理,从中手动编辑出部分类Foo定义并添加Using语句来手动完成此任务。 I'd like to do it without hand-editing if possible. 如果可能的话,我希望无需手动编辑即可。

It seems like maybe the answer is to use SVCUTIL.EXE instead of WSDL.EXE. 似乎答案可能是使用SVCUTIL.EXE而不是WSDL.EXE。 There are two intriguing options: /R and /ET. 有两个有趣的选项:/ R和/ ET。 I tried putting /ET:Foo and /ET:My.FQN.Util.Foo, and /ET:www.my.com.the.servicenamespace.Foo, and also adding the DLL filename to the option. 我尝试将/ ET:Foo和/ET:My.FQN.Util.Foo和/ET:www.my.com.the.servicenamespace.Foo放入,并且还将DLL文件名添加到该选项中。 But nothing changes in the ServiceWithFoos.cs proxy class that gets created. 但是在创建的ServiceWithFoos.cs代理类中没有任何更改。 The partial class definition for Foo is still there. Foo的局部类定义仍然存在。

Am I on the right track? 我在正确的轨道上吗? What am I doing wrong? 我究竟做错了什么?

Add [DataContract(Namespace = "http://anything.here")] to your Foo type, then use svcutil with the /r option taking the path of the library containing Foo. [DataContract(Namespace = "http://anything.here")]添加到您的Foo类型,然后将svcutil与/ r选项一起使用,以获取包含Foo的库的路径。 This way svcutil should see the same contract namespace and map Foo correctly. 这样,svcutil应该看到相同的协定名称空间并正确映射Foo。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM