C# 更新服务参考在 WCF 中不起作用
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/16556684/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Update Service Reference is not working in WCF
提问by ujjaval
I am using VS 2012.
我正在使用 VS 2012。
I add services reference to my WPF project, but when I've changed my services and updated service reference my Reference.svcmap -> Reference.CS file will be blank and I can't use reference anymore. I can see it in project, but I can't use.
我向我的 WPF 项目添加了服务引用,但是当我更改了我的服务并更新了服务引用时,我的 Reference.svcmap -> Reference.CS 文件将是空白的,我不能再使用引用了。我在项目中可以看到它,但我无法使用。
My settings of Services References are :-

我的服务参考设置是:-

Reference.cs file
参考.cs文件
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.17929
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
回答by Damith
There are few things you can do first Clean the solution, delete the output directory and the service reference. Restart the Visual Studio and re configure the web service. Hope this helps.
您可以先清理解决方案,删除输出目录和服务引用。重新启动 Visual Studio 并重新配置 Web 服务。希望这可以帮助。
回答by alan
If you cannot browse the URL, then you will not be able to add the service reference. Try hosting your web service locally in IIS. When you're able to browse the URL, then you can add the service reference.
如果您无法浏览 URL,则您将无法添加服务引用。尝试在 IIS 中本地托管您的 Web 服务。当您能够浏览 URL 时,您就可以添加服务引用。
回答by Abhishek B Patel
uncheck the Reuse types in referenced assemblies checkbox and put address of your new service in Address textbox.
取消选中引用程序集中的重用类型复选框,并将新服务的地址放在地址文本框中。
回答by Dhivya DD
While configuring service reference append /mex(address of your end point with mexHttpBinding ) at the end of your service URL.
在配置服务引用时,在服务 URL 的末尾附加/mex(使用 mexHttpBinding 的端点地址)。
This will enable metadata exchange. So Reference.cs will be modified / added (if you are adding service reference for the first time).
这将启用元数据交换。所以 Reference.cs 将被修改/添加(如果您是第一次添加服务引用)。
Edit: On analysis I found that this issue happens when a service (which implements one ServiceContract) is exposed via more than one end point.
编辑:经过分析,我发现当一项服务(实现一个 ServiceContract)通过多个端点公开时会发生此问题。
This issue can be avoided by using different Service Contracts (Interface) for each end point and making the service class (service1) implement all these Interfaces.
通过为每个端点使用不同的服务契约(接口)并使服务类 (service1) 实现所有这些接口,可以避免这个问题。
回答by gatsby
Unchecking the reuse option the Update Service option works fine.
取消选中重用选项更新服务选项工作正常。
回答by Orlando Seixas
It can be caused by Team Foundation source control. Try to right click on the service ref and choose "Check out for edit..." Than update service reference again.
它可能是由 Team Foundation 源代码控制引起的。尝试右键单击服务引用并选择“签出以进行编辑...”然后再次更新服务引用。

