Reputation: 296
I have a local service made with ServiceStack and I want to call a method from my Xamarin.Forms application:
ServiceStack.JsonServiceClient sc;
sc = new ServiceStack.JsonServiceClient("http://api.sportsstars.local/");
When the debugger reaches the second line, it throws this exception:
System.TypeInitializationException: An exception was thrown by the type initializer for ServiceStack.ServiceClientBase
Any ideas what could it be?
Upvotes: 0
Views: 348
Reputation: 296
I have found out how to avoid the exception. I've put the code in the Droid project and used a DependencyService to call the method from my PCL project. My problem was for Android. If you get the problem for IOS, the other answer may help you.
Upvotes: 0
Reputation: 143319
Have you initialized the PCL Client? You can configure it by adding:
ServiceStack.IosPclExportClient.Configure();
To your application on StartUp.
Upvotes: 1