Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using ServiceStack.Client on Xamarin.iOS

We are trying to use the ServiceStack clients on a Xamarin project and we are failing to make it work. We see that only very recently the PCL has been added to nuget, which we are trying to use right now.

If we add ServiceStack.Client.Pcl v4.0.7 with the following line (anywhere) it fails on iOS:

var client = new JsvServiceClient("http://localhost/");

When debugging it, it seems to fail on PclExportClient.Instance, which returns a null reference in the constructor of ServiceClientBase. When trying the same on an Android project it does seem to work just fine.

Are we doing something wrong or is the PCL simply not ready yet and should we instead try to approach it in a different way? I have been looking at the RemoteInfo example, which does seem to work, but that is still using V3 and we prefer to work with the latest version.

We've also tried running the PclTest, but when running that we get the very same error:

enter image description here

If you have any ideas what we are doing wrong or if you know of an alternative way to get this working on Xamarin.iOS, please let us know.

like image 425
LuukWeltevreden Avatar asked Jan 19 '14 15:01

LuukWeltevreden


1 Answers

From the Hello World iOS PCL Project:

The first line of code is to register the PCL Provider for iOS, normally this is automatically inferred but as it sometimes doesn't get picked up for iOS, it's recommended to explicitly register it with:

IosPclExportClient.Configure();
like image 187
mythz Avatar answered Nov 18 '22 17:11

mythz