WCF 4.0、.NET 2.0 客户端和 .NET 类型

发布于 2024-10-19 16:27:50 字数 873 浏览 3 评论 0原文

这是我的场景:

  • 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

毁梦 2024-10-26 16:27:50

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文