简体   繁体   English

无法在同一解决方案中为WCF项目的客户端类添加服务引用

[英]Can't add service reference to client class for WCF project within same solution

I'm working through an example on a website to create and consume a WCF service. 我正在通过网站上示例来创建和使用WCF服务。 I've created the service which is hosted in a windows application. 我已经创建了托管在Windows应用程序中的服务。

As per the instructions on the site I've created a ClientApp console app within in the same Visual Studio solution. 根据网站上的说明,我在同一个Visual Studio解决方案中创建了一个ClientApp控制台应用程序。 Now the problem is that I cannot create a service reference to the WCF host project. 现在的问题是我无法创建对WCF主机项目的服务引用。

If I run the host project the Service is switched on and I can verify this by visiting the url in my browser. 如果我运行主机项目,则服务已打开,我可以通过访问浏览器中的URL来验证这一点。 However, I cannot add a service reference to my client project while another project is running. 但是,当另一个项目正在运行时,我无法向我的客户端项目添加服务引用。 The "Add Service Reference" option is greyed out. “添加服务引用”选项显示为灰色。 Presumably this is since they're in the same solution in Visual Studio. 据推测,这是因为他们在Visual Studio中使用相同的解决方案。

If I try and add the reference when the host project is not running then I can get into the "Add Service Reference" screen but no services can be found (presumably because the WCF service is no longer running 如果我尝试在主机项目未运行时添加引用,那么我可以进入“添加服务引用”屏幕,但是找不到任何服务(可能是因为WCF服务不再运行

How can I get around this? 我怎么能绕过这个?

The solution explorer is as in the image: 解决方案资源管理器如图所示:

在此输入图像描述

You could also try to start the WCF service in Visual Studio, then select "Detach All" from the Debug menu. 您还可以尝试在Visual Studio中启动WCF服务,然后从“调试”菜单中选择“全部分离”。 This should let the service continue to run in the background, yet open Visual Studio to let you add service references. 这应该让服务继续在后台运行,但是打开Visual Studio以允许您添加服务引用。

In the Add Service Reference dialog, click the Discover button and select Services in Solution: 在Add Service Reference对话框中,单击Discover按钮并选择Services in Solution:

在此输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 无法使用netTcpBinding将WCF服务引用添加到客户端项目 - Can't add WCF service reference to client project using netTcpBinding 为什么我不能在同一解决方案中的另一个项目中引用另一个命名空间中的类? - Why can't I reference a class in another namespace in another project within the same solution? C# UWP - 无法在同一解决方案中添加对项目的引用 - C# UWP - Can't add reference to project in same solution 使用客户端证书将 WCF 服务引用添加到 Visual Studio 2022 项目 - Add WCF Service Reference to Visual Studio 2022 Project with Client Certificate WCF服务库项目找不到对其他项目的引用 - WCF service library project can't find reference to other project 无法将Azure VM上托管的WCF服务引用添加到VS2015项目 - Can't add WCF service reference hosted on Azure VM to VS2015 project WCF服务参考和对同一项目的参考 - WCF Service Reference and Reference to same project WCF服务未更新(多个项目,相同的解决方案) - WCF Service Not Updating (Multi project, same solution) 无法将服务引用添加到自托管WCF服务 - Can't Add Service Reference to self-hosted WCF Service 我无法将WCF参考添加到Windows Mobile项目吗? - I can't add WCF reference to windows mobile project?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM