Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Adding service reference to portable class library

I am making a portable C# class library and I am trying to add a web service reference to my project.

Using VS 2013, I right click on the solution and in my other projects there would be an option to "Add service reference." But in my mobile library project that option does not exist.

Is there something special one needs to do to add a service reference to a mobile library or is it not possible?

See screenshot, there isn't even an option to add a service reference to my project.

enter image description here

like image 538
Giardino Avatar asked Nov 20 '14 16:11

Giardino


People also ask

How do I add an existing 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. In the Address box, enter the URL for the service, and then click Go to search for the service.

How do I add a Web service reference in Visual Studio 2010?

In Solution Explorer, right-click the name of the project to add the Web service to and then click Add Web Reference. The Add Web Reference dialog box is displayed. In the URL box, enter the URL of the Web service to use.


3 Answers

I was having the same problem. Right after creation of a new project of type "Blank App (Xamarin.Forms Shared) in Visual Studio there was no "Add Service Reference" link when I right clicked on PCL. What I did was I just created another PCL and referenced it instead of default one (which I deleted later). I chose project of type "Class Library (Portable for iOS, Android and Windows)".

enter image description here

And then I went to project's properties and unselected "Windows Phone 8.1" checkbox.

enter image description here

And "Add Service Reference" link appeared all over the sudden.

enter image description here

I am using Visual Stuido 2015 Community Edition (version 14.0.25123.00 Update 2). Hope this will work for you guys too.

like image 106
Aleksei Mialkin Avatar answered Oct 09 '22 12:10

Aleksei Mialkin


The reason you can't add Service Reference in a Xamarin Forms PCL project can be:

  1. Windows Phone 8.1 (not Silverlight). Remove it by going to properties on PCL project and click Change. You might not be able to do it before you remove all your Nuget Packages.
  2. Visual Studio crashes when you add the service reference. Remove Xamarin Forms nuget package and Asp.net SignalR. That worked for me. I didn't have Entity Framework Core but that might have to be removed temporarily as well.
like image 20
Flemming Bonde Kentved Avatar answered Oct 09 '22 12:10

Flemming Bonde Kentved


Add Reference "System.ServiceModel" and can you see "Service Reference"

like image 44
Charly Contreras Avatar answered Oct 09 '22 13:10

Charly Contreras