Skip to content

InvalidCastException when setting LicenseKey #19

@harry-gordon

Description

@harry-gordon

I'm trying to get started with MR.Gestures in our Xamarin.Forms/MvvmCross project but I'm getting an exception from inside MR.Gestures when trying to set the licence key in MainActivity as per the Getting Started instructions:

protected override void OnCreate(Bundle bundle)
{
    ...
    base.OnCreate(bundle); // MVVM sets up Xamarin.Forms here
    MR.Gestures.Android.Settings.LicenseKey = "<licence key>";
    ...
}

The exception trace:

07-12 11:35:04.259 I/MonoDroid(10865): UNHANDLED EXCEPTION:
07-12 11:35:04.298 I/MonoDroid(10865): System.InvalidCastException: Specified cast is not valid.
07-12 11:35:04.298 I/MonoDroid(10865):   at MR.Gestures.Android.Settings.get_AppName () [0x00005] in <c63931d951104a8ba883711522cfb229>:0 
07-12 11:35:04.298 I/MonoDroid(10865):   at MR.Gestures.Android.Settings.set_LicenseKey (System.String value) [0x0000a] in <c63931d951104a8ba883711522cfb229>:0 
07-12 11:35:04.298 I/MonoDroid(10865):   at TestApp.Android.MainActivity.OnCreate

I've tried moving where we set the licence key around (including 1. finding a hook in MVVM Cross to set it between XF init and LoadApplication and 2. much later just before the component is needed) but I've had the same results.

Any help would be appreciated! Let me know if you have any questions.

For reference we are on XF version 3.6.0 and MvvmCross version 6.2.3.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions