Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Specified cast is not valid." on android #4

Open
karlingen opened this issue Apr 17, 2018 · 1 comment
Open

"Specified cast is not valid." on android #4

karlingen opened this issue Apr 17, 2018 · 1 comment

Comments

@karlingen
Copy link

Getting a System.InvalidCastException from this line:

https://github.com/wislon/xfdemos/blob/master/src/xamformsdemo/xamformsdemo.Droid/Effects/ChangeColorSwitchEffect.cs#L73

protected override void OnDetached()
    {
      if (Android.OS.Build.VERSION.SdkInt >= Android.OS.BuildVersionCodes.JellyBean)
      {
        ((Switch)Control).CheckedChange -= OnCheckedChange;
      }
    }

It works on iOS. Any idea why?

@wislon
Copy link
Owner

wislon commented Apr 29, 2018

I'm sorry I only saw this notification now... :(

I'm really not sure. I've just spun it up on a Nougat 7.1 device and it seems to work fine (just a clone, build, run). It's quite possible that newer versions of Android SDK and/or Xamarin Forms may be to blame (this demo is a bit old, I think I'll at least update the packages soon).

Last thing: did you try casting it to SwitchCompat instead? It might have been an oversight on my part (since the CheckedChange event wire-up was done to a SwitchCompat further up). In which case I apologise.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants