使用 slsvcutil.exe 引用共享 Silverlight 程序集
我有多个 WCF 服务被不同的 Silverlight 应用程序使用。我目前正在使用 slsvcutil.exe 和相当标准的设置来生成我的 Silverlight 代理对象:
"%ProgramFiles%\microsoft sdks\silverlight\v4.0\tools\slsvcutil.exe" http://myhost/MyService.svc?wsdl /out:Proxy.cs /edb /namespace:"*,My.Namespace" /ct:System.Collections.ObjectModel.ObservableCollection`1 /r:"%ProgramFiles%\Microsoft Silverlight\4.0.50524.0\System.Windows.dll"
我想做的是共享一些类型,特别是基本 多个服务及其生成的 Silverlight 代理之间的 RequestMessage
、ResponseMessage
和 ApplicationFault
。我希望这些类型位于它们自己的公共 Silverlight 命名空间中,以便我可以使用共享的 Silverlight 代码来轮询服务请求或检查 SOAP 错误并将其转换为可以引发的已知异常类型。
我认为这可以通过使用 slsvcutil.exe 上的 /r 或 /reference 开关来完成,方法是指定具有共享类型的 DLL 的路径。我尝试像这样构建代理,但它似乎仍然为我试图共享的对象生成新的不兼容类型:
"%ProgramFiles%\microsoft sdks\silverlight\v4.0\tools\slsvcutil.exe" http://myhost/Service.svc?wsdl /out:Proxy.cs /edb /namespace:"*,My.Namespace" /ct:System.Collections.ObjectModel.ObservableCollection`1 /r:"%ProgramFiles%\Microsoft Silverlight\4.0.50524.0\System.Windows.dll" /r:"C:\path\to\MySharedTypes.dll"
关于可能出现问题的任何想法?或者我对 /r 开关与 slsvcutil.exe 的用途有什么错误的印象吗?
I have several WCF services being consumed by different Silverlight applications. I am currently using slsvcutil.exe with a pretty standard setup to generate my Silverlight proxy objects:
"%ProgramFiles%\microsoft sdks\silverlight\v4.0\tools\slsvcutil.exe" http://myhost/MyService.svc?wsdl /out:Proxy.cs /edb /namespace:"*,My.Namespace" /ct:System.Collections.ObjectModel.ObservableCollection`1 /r:"%ProgramFiles%\Microsoft Silverlight\4.0.50524.0\System.Windows.dll"
What I would like to do is share some types, specifically a base RequestMessage
, ResponseMessage
, and ApplicationFault
between the multiple services and their generated Silverlight proxies. I would like these types to be in their own common Silverlight namespace so that I can use shared Silverlight code to do things poll a service request or check for a SOAP fault and translate it into a known exception type that can be thrown.
I thought that this could be done by using the /r or /reference switch on slsvcutil.exe by specifying the path to the DLL with the shared types. I tried building the proxy like this but it still seemed to be generating new incompatible types for the objects I was trying to share:
"%ProgramFiles%\microsoft sdks\silverlight\v4.0\tools\slsvcutil.exe" http://myhost/Service.svc?wsdl /out:Proxy.cs /edb /namespace:"*,My.Namespace" /ct:System.Collections.ObjectModel.ObservableCollection`1 /r:"%ProgramFiles%\Microsoft Silverlight\4.0.50524.0\System.Windows.dll" /r:"C:\path\to\MySharedTypes.dll"
Any ideas on what might be going wrong? Or do I have the wrong impression of what the /r switch can be used for with slsvcutil.exe?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论