This is Xamarin's bug tracking system. For product support, please use the support links listed in your Xamarin Account.
Bug 47577 - handle must valid, Parameter name: instance
Summary: handle must valid, Parameter name: instance
Alias: None
Product: Android
Classification: Xamarin
Component: Mono runtime / AOT Compiler (show other bugs)
Version: 7.0 (C8)
Hardware: PC Windows
: --- normal
Target Milestone: ---
Assignee: Jonathan Pryor
Depends on:
Reported: 2016-11-21 14:29 UTC by contatti
Modified: 2017-04-07 08:55 UTC (History)
4 users (show)

See Also:
Tags: XATriaged
Is this bug a regression?: ---
Last known good build:

Android monitor log (6.08 KB, text/plain)
2016-11-21 14:29 UTC, contatti

Description contatti 2016-11-21 14:29:18 UTC
Created attachment 18571 [details]
Android monitor log


I use a JavaList<> as data for my RecyclerView. The app works normally, but from a recent update the app crash with this error:
Unhandled Exception:
System.ArgumentException: Handle must be valid.
Parameter name: instance

This happen when I use with the JavaList (method doesn't matter, can be Count, [], etc).
In Android Monitor i get this additional information:
 at Java.Interop.JniEnvironment+InstanceMethods.CallIntMethod (Java.Interop.JniObjectReference instance, Java.Interop.JniMethodInfo method) [0x0000d] in <a043032cf94a485190047a14918b9f60>:0 

I attach the entire log I got from Android Monitor
Comment 1 contatti 2016-11-23 09:08:25 UTC
Dude, it's a serious bug. I can confirm because now it happen in another app! Ask for detail, but fix it!
Comment 2 contatti 2016-11-23 12:12:12 UTC
I try to downgrade Xamarin to the last version of Cycle 7. It works.
The problem it happens only with version 8.
Comment 3 Jonathan Pryor 2016-11-23 16:44:36 UTC
@contatti: Xamarin.Android 7.0 ("Cycle 8") changed the default bridge from "old" to "tarjan". Please try using the "old" implementation:


If that fixes the issue, you found a GC bridge bug. (Yay?) If possible, please attach a test case so that our GC team can fix it.
Comment 4 contatti 2016-11-25 09:30:59 UTC
I try your suggest and it works! 

I will create a test case on next monday, however I can tell you I use the object JavaList<> as data inside a Android.Support.V4.App.Fragment

Comment 5 contatti 2016-11-28 12:00:23 UTC
I try to create a test case, but I am unable to reproduce the bug.

Maybe we can try with a full app?
Comment 6 Jonathan Pryor 2016-11-28 16:46:55 UTC
@contatti: If you can provide the full app and repro instructions, that would be fine.
Comment 7 Rodrigo Kumpera 2017-02-22 23:23:53 UTC

Do we have an update on this?
Comment 8 contatti 2017-04-06 07:19:04 UTC
It seems now fixed. Apologize me for lack of updates, but my job keep me very busy.

Comment 9 contatti 2017-04-07 08:55:07 UTC

Unfortunately after an extensive test the problem still appear.
In these days I do not have much time, I try to recreate the problem in a sample with no success.

Note You need to log in before you can comment on or make changes to this bug.