WCF:更新服务参考提供重复的配置条目

发布于 2024-08-14 06:00:36 字数 380 浏览 3 评论 0原文

我有一个使用 WCF 服务的服务引用的 WPF 应用程序。在对服务进行更新时,我需要更新服务引用,因此我右键单击它并点击“更新服务引用”。

执行此操作会导致客户端项目的 App.config 文件中出现重复条目​​。

  • 它复制了 wsHttpBinding 下的绑定 - 添加一个名称中带有后缀编号的相同条目:WSHttpBinding_ISomeService --> WSHttpBinding_ISomeService1
  • 它复制了绑定下的端点定义,以便每个 wsHttpBinding 都有一个端点。除了名称之外,这也是纯粹的重复。

为什么它会重复配置?不是应该更新一下名字吗?我怎样才能让它停止?

I have a WPF application using service references to a WCF service. When doing updates on the service I need to update the service reference, so I right click it and hit "Update Service Reference".

Doing this results in duplicate entries in the App.config file of the client project.

  • It duplicates a binding under wsHttpBinding - adding an equal entry with postfix number in name: WSHttpBinding_ISomeService --> WSHttpBinding_ISomeService1.
  • And it duplicates the endpoint definition under binding such that there is one endpoint for each wsHttpBinding. This too is a pure duplicate except of the name.

Why does it duplicate the config? Isn't it just supposed to update the name? And how can I make it stop?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(4

无法回应 2024-08-21 06:00:36

您使用的是哪个版本的 Visual Studio?这是一个已知的错误,已在 VS2010 中修复。查看此链接

Which version of Visual Studio are you using? This is a known bug, which has been fixed in VS2010. Check out this link!

梓梦 2024-08-21 06:00:36

code-zoop 说这个已知的错误在 VS2010 中已得到解决,但我也在 VS2010 中得到了它。

当我手动修改 App.config 中 basicHttpBinding 的 MaxReceivedMessageSize 属性(和其他属性)的默认值时会发生这种情况(根据这篇文章:WCF - 如何增加消息大小配额

只是想我会提到这也发生在 VS2010 中。目前,我正在采纳 Shiraz Bhaiji 的建议,只是删除重复项,这目前看来有效。

code-zoop says that this known bug is resolved in VS2010, but I'm getting it in VS2010 as well.

Happens when I manually modify the default value for the MaxReceivedMessageSize property (and others) of the basicHttpBinding in App.config (as per this post: WCF - How to Increase Message Size Quota)

Just thought I'd mention that this happens in VS2010 as well. For the moment, I'm taking Shiraz Bhaiji's advice and just deleting the duplicate, which seems to be working for the moment being.

别把无礼当个性 2024-08-21 06:00:36

这种情况也曾多次发生在我们身上。

您需要删除重复项,否则它将在运行时崩溃。客户端在配置文件中查找应该向接口(WCF 合约 X)发送请求的位置,发现多个,然后崩溃。

This has also happend to us on a few occasions.

You need to remove the duplicate, otherwise it will crash at runtime. The client looks in the configuration file to find where it should send a request to Interface(WCF contract X), finds more than one, and crashes.

紧拥背影 2024-08-21 06:00:36

一种解决方法是将服务代理(Web 引用)放入其自己的 DLL 中,并从主项目中引用它。

当您执行 Update Referene 时,它不会影响您的 web.config 中的服务代理配置,并且作为奖励,如果您需要比较默认值,您将拥有一个具有最新服务代理配置的项目使用 web.config 中实际配置进行配置

还有一个好处,即如果您有一个服务代理引用另一个服务代理,它将共享类型

MAIN DLL > ServiceAgent1 DLL > ServiceAgent2 DLL

如果 ServiceAgent1 和 ServiceAgent2 具有共享类型,您将不会获得两个生成的重复类

one workaround is to put the service agent (web reference) in its own DLL and reference it from the main project.

it won't touch your service agent config in your web.config when you do Update Referene and as a bonus you'll have a project with up to date serviceagent config if you ever need to compare the default configuration with what you actually have in web.config

also has the benefit that if you have one service agent referencing another it will share the types

MAIN DLL > ServiceAgent1 DLL > ServiceAgent2 DLL

If ServiceAgent1 and ServiceAgent2 have shared types you won't get two generated duplicate classes

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