Unable to add service reference to client class for WCF project within the same solution

I am working on an example on a website to create and use a WCF service. I created a service hosted in a Windows application.

Following the instructions on the site, I created the ClientApp console application in one Visual Studio solution. Now the problem is that I cannot create a service link for the WCF host project.

If I run the host project, the service is turned on, and I can verify this by visiting the url in my browser. However, I cannot add a service link for my client project while another project is running. The "Add Service Link" option is grayed out. Presumably, this is because they are in the same solution in Visual Studio.

If I try to add a link when the host project is not running, I can enter the β€œAdd service link” screen but no services are found (probably due to the WCF service no longer working

How can I get around this?

The solution explorer is the same as in the image:

enter image description here

+5
source share
2 answers

You can also try starting the WCF service in Visual Studio, and then select Detach All from the Debug menu. This should allow the service to continue to run in the background, but open Visual Studio so that you can add links to the services.

+8
source

In the Add Service Link dialog box, click the Discovery button and select Services in Solution:

enter image description here

+1
source

Source: https://habr.com/ru/post/1213451/


All Articles