ServiceStack.Licensing.RegisterLicense exception on Xamarin Android

485 views Asked by At

I'm getting an exception with a call to ServiceStack.Licensing.RegisterLicense(string license) in a Xamarin Android App (this is a trivial concept app):

{ System.TypeInitializationException: An exception was thrown by the type initializer for ServiceStack.LicenseUtils ---> System.NullReferenceException: Object reference not set to an instance of an object
at ServiceStack.LicenseUtils..cctor () [0x00000] in :0 --- End of inner exception stack trace ---
at ServiceStack.Licensing.RegisterLicense (System.String licenseKeyText) [0x00000] in :0
at ServiceStackLicker.MainActivity+<>c__DisplayClass1.b__0 (System.Object param0, System.EventArgs param1) [0x0003b] in c:\Users\ibLang\Documents\Projects\ServiceStackLicker\ServiceStackLicker\MainActivity.cs:35

} System.TypeInitializationException

This is reproduced with just a blank Xamarin Android App with the ServiceStack.Text package installed. This code works fine in my other portable class libraries that use ServiceStack.Text, so I know that the license is valid.

In further investigation, I'm finding that I can't even make a simple Xamarin Android app do anything with ServiceStack.Text.

Does this work with Xamarin Android apps? Am I completely missing some initialization that I have in my other libraries? Is there a bug? What up!?

1

There are 1 answers

0
mythz On BEST ANSWER

In order to use the ServiceStack PCL libraries you need to install the ServiceStack.Client NuGet package, i.e:

PM> Install-Package ServiceStack.Client

This will also install the ServiceStack.Text package but more importantly the required PCL adapters for the different supported PCL providers like Android, iOS, etc.