WCF 4.0、.NET 2.0 客户端和 .NET 类型
这是我的场景:
- WCF 4.0 服务
- .NET 2.0 客户端(使用上述服务)
我需要传递一组 NetworkInterfaces
(System.Net.NetworkInformation.NetworkInterfaces< /code>) 从客户端到服务。 WCF 服务的 Web 引用
wcfReference
已添加到客户端。
服务代码:
public void StoreNetworkInterfaces(System.Net.NetworkInterfaces[] nwInterfaces)
{
...
}
客户端代码:
wcfService.StoreNetworkInterfaces(System.Net.NetworkInformation.NetworkInterfaces.GetAllNetworkInterfaces());
我得到:
参数 1:无法从 'System.Net.NetworkInformation.NetworkInterface[]' 转换为 'WindowsFormsApplication1.wcfReference.NetworkInterface[]'
对于任何其他情况也会发生同样的情况类型(.NET 和非 .NET 类型)。我知道这是 Web 服务(互操作)所需的行为,但我的 WCF 的范围仅服务于客户端安装程序。
对于该项目来说,在每次 Web 参考更新后手动更改代理代码绝对不是一个好的选择。
任何帮助或方法建议将不胜感激。
问候
This is my scenario:
- WCF 4.0 service
- .NET 2.0 client (that consumes the above service)
I need, let's say, to pass an array of NetworkInterfaces
(System.Net.NetworkInformation.NetworkInterfaces
) from the client to the service. A web reference wcfReference
to WCF service has been added to the client side.
Service code:
public void StoreNetworkInterfaces(System.Net.NetworkInterfaces[] nwInterfaces)
{
...
}
Client code:
wcfService.StoreNetworkInterfaces(System.Net.NetworkInformation.NetworkInterfaces.GetAllNetworkInterfaces());
I'm getting:
Argument 1: cannot convert from 'System.Net.NetworkInformation.NetworkInterface[]' to 'WindowsFormsApplication1.wcfReference.NetworkInterface[]'
Same happens for any other types (.NET and non .NET types). I know this is the desired behaviour for a web service (interop) but the scope of my WCF is just serving to a client installer.
Manually changing proxy code after each Web Reference update is definitively not a good choice for this project.
Any help or approach suggestion would be very appreciated.
Greets
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Web 引用(2.0 样式)没有完整 WCF(3.0+)服务引用支持的“重用类型”选项,因此如果您使用该工具,您将必须通过网络接受代理类型,然后将它们(可能是 AutoMapper)转换为域类型或从域类型转换它们。
请勿编辑参考文件;可以随机再生。
A web-reference (2.0-style) doesn't have the "re-use types" option that full a WCF (3.0+) service-reference supports, so if you use the tooling you are going to have to accept the proxy types over the wire, and then transform them (perhaps AutoMapper) to/from the domain types.
Do not edit the reference file; that may be regenerated randomly.