Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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:

enter image description here

like image 821
Sperick Avatar asked Feb 16 '15 11:02

Sperick


People also ask

How do I change my WCF service reference?

In Solution Explorer, right-click the name of the project to which you want to add the service, and then click Add Service Reference. The Add Service Reference dialog box appears. Click Discover. All services (both WCF Data Services and WCF services) in the current solution are added to the Services list.

How do I add a WCF service reference to the console application?

Select the Build tab; check whether "Any CPU" is selected for Platform Target. In the Solution Explorer, right click on the References folder and click on Add Service Reference. The Add Service Reference wizard will pop up. In the Address section, enter the WCF service URL and then click on Go button.


1 Answers

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.

like image 89
GTHvidsten Avatar answered Oct 19 '22 18:10

GTHvidsten