简体   繁体   中英

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. I've created the service which is hosted in a windows application.

As per the instructions on the site I've created a ClientApp console app within in the same Visual Studio solution. Now the problem is that I cannot create a service reference to the WCF host project.

If I run the host project the Service is switched on and I can verify this by visiting the url in my browser. 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.

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

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. This should let the service continue to run in the background, yet open Visual Studio to let you add service references.

In the Add Service Reference dialog, click the Discover button and select Services in Solution:

在此输入图像描述

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM