Bug 41639 - ArgumentException when changing the icon of a ToolbarItem at runtime (Android)
Summary: ArgumentException when changing the icon of a ToolbarItem at runtime (Android)
Status: RESOLVED FIXED
Alias: None
Product: Forms
Classification: Xamarin
Component: Android ()
Version: 2.2.0
Hardware: PC Windows
: --- normal
Target Milestone: ---
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2016-06-09 09:01 UTC by i1387552
Modified: 2016-11-03 22:31 UTC (History)
5 users (show)

Tags: ac
Is this bug a regression?: ---
Last known good build:


Attachments
Test project (49.07 KB, application/zip)
2016-06-09 09:01 UTC, i1387552
Details


Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED FIXED

Description i1387552 2016-06-09 09:01:58 UTC
Created attachment 16243 [details]
Test project

In our Android (AppCompat) app we are getting a ArgumentException: 'jobject' must not be IntPtr.Zero when changing the icon of a ToolbarItem at runtime. Forms version is 2.2.0.45

I attached a test project. Switch to 'Page 3' and than back to 'Page 1' and click on the toggle button to get the exception.

System.ArgumentException: 'jobject' must not be IntPtr.Zero. Parameter name: jobject
  at Android.Runtime.JNIEnv.CallObjectMethod (IntPtr jobject, IntPtr jmethod) [0x00010] in /Users/builder/data/lanes/3236/ee215fc9/source/monodroid/src/Mono.Android/src/Runtime/JNIEnv.g.cs:170 
  at Android.Views.View.get_Context () [0x0002d] in /Users/builder/data/lanes/3236/ee215fc9/source/monodroid/src/Mono.Android/platforms/android-23/src/generated/Android.Views.View.cs:4891 
  at Xamarin.Forms.Platform.Android.AppCompat.NavigationPageRenderer.UpdateMenu () [0x00006] in C:\BuildAgent2\work\aad494dc9bc9783\Xamarin.Forms.Platform.Android\AppCompat\NavigationPageRenderer.cs:643 
  at Xamarin.Forms.Platform.Android.AppCompat.NavigationPageRenderer.HandleToolbarItemPropertyChanged (System.Object sender, System.ComponentModel.PropertyChangedEventArgs e) [0x00045] in C:\BuildAgent2\work\aad494dc9bc9783\Xamarin.Forms.Platform.Android\AppCompat\NavigationPageRenderer.cs:387 
  at (wrapper delegate-invoke) <Module>:invoke_void_object_PropertyChangedEventArgs (object,System.ComponentModel.PropertyChangedEventArgs)
  at Xamarin.Forms.BindableObject.OnPropertyChanged (System.String propertyName) [0x0000a] in C:\BuildAgent2\work\aad494dc9bc9783\Xamarin.Forms.Core\BindableObject.cs:137 
  at Xamarin.Forms.Element.OnPropertyChanged (System.String propertyName) [0x00000] in C:\BuildAgent2\work\aad494dc9bc9783\Xamarin.Forms.Core\Element.cs:362 
  at Xamarin.Forms.BindableObject.SetValueActual (Xamarin.Forms.BindableProperty property, Xamarin.Forms.BindablePropertyContext context, System.Object value, Boolean currentlyApplying, SetValueFlags attributes, Boolean silent) [0x000f4] in C:\BuildAgent2\work\aad494dc9bc9783\Xamarin.Forms.Core\BindableObject.cs:581 
  at Xamarin.Forms.BindableObject.SetValueCore (Xamarin.Forms.BindableProperty property, System.Object value, SetValueFlags attributes, SetValuePrivateFlags privateAttributes) [0x0014b] in C:\BuildAgent2\work\aad494dc9bc9783\Xamarin.Forms.Core\BindableObject.cs:378 
  at Xamarin.Forms.BindableObject.SetValue (Xamarin.Forms.BindableProperty property, System.Object value, Boolean fromStyle, Boolean checkAccess) [0x0005f] in C:\BuildAgent2\work\aad494dc9bc9783\Xamarin.Forms.Core\BindableObject.cs:531 
  at Xamarin.Forms.BindableObject.SetValue (Xamarin.Forms.BindableProperty property, System.Object value) [0x00000] in C:\BuildAgent2\work\aad494dc9bc9783\Xamarin.Forms.Core\BindableObject.cs:83 
  at Xamarin.Forms.MenuItem.set_Icon (Xamarin.Forms.FileImageSource value) [0x00000] in C:\BuildAgent2\work\aad494dc9bc9783\Xamarin.Forms.Core\MenuItem.cs:37 
  at TestDroid.Page1.ToggleClicked (System.Object sender, System.EventArgs e) [0x0003a] in /Users/quadcore/Projects/TestDroid/Page1.xaml.cs:21 
  at Xamarin.Forms.Button.Xamarin.Forms.IButtonController.SendClicked () [0x00020] in C:\BuildAgent2\work\aad494dc9bc9783\Xamarin.Forms.Core\Button.cs:122 
  at Xamarin.Forms.Platform.Android.AppCompat.ButtonRenderer+ButtonClickListener.OnClick (Android.Views.View v) [0x0000b] in C:\BuildAgent2\work\aad494dc9bc9783\Xamarin.Forms.Platform.Android\AppCompat\ButtonRenderer.cs:274 
  at Android.Views.View+IOnClickListenerInvoker.n_OnClick_Landroid_view_View_ (IntPtr jnienv, IntPtr native__this, IntPtr native_v) [0x00011] in /Users/builder/data/lanes/3236/ee215fc9/source/monodroid/src/Mono.Android/platforms/android-23/src/generated/Android.Views.View.cs:1903 
  at (wrapper dynamic-method) System.Object:041a8b72-2872-4ad9-896f-b5245b1c2421 (intptr,intptr,intptr)
Comment 1 Giorgos Papadakis 2016-10-20 13:24:52 UTC
Also have exact the same problem
Comment 2 Paul DiPietro [MSFT] 2016-11-03 22:31:49 UTC
This looks to no longer be occurring as of 2.3.3.166-pre4.