[英]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.