Bug 26528 - NullReferenceException in Android.PickerRender.UpdatePicker()
Summary: NullReferenceException in Android.PickerRender.UpdatePicker()
Alias: None
Product: Forms
Classification: Xamarin
Component: Forms ()
Version: 1.3.1
Hardware: PC Mac OS
: Normal normal
Target Milestone: 1.3.5
Assignee: Bugzilla
Depends on:
Reported: 2015-01-29 00:55 UTC by Prashant Cholachagudda
Modified: 2015-02-18 09:51 UTC (History)
8 users (show)

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

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:

Description Prashant Cholachagudda 2015-01-29 00:55:05 UTC
Customer defined a Picker in XAML and in the code he adds the items from the code in OnAppearing method. Once you switch to other tab and back to main screen and try to change the picker item the XF throws a NullReferenceException

Sample code and steps to reproduce are in the private comment below.

System.Diagnostics.Debugger.Mono_UnhandledException (ex={System.NullReferenceException: Object reference not set to an instance of an object
at Xamarin.Forms.Platform.Android.PickerRenderer.UpdatePicker () <IL 0x0000c, 0x00052>
at Xamarin.Forms.Platform.Android.PickerRenderer.RowsCollectionChanged (object,System.EventArgs) <IL 0x00001, 0x00027>
at (wrapper delegate-invoke) <Module>.invoke_void_object_NotifyCollectionChangedEventArgs (object,System.Collections.Specialized.NotifyCollectionChangedEventArgs) <IL 0x00044, 0x0007c>
at (wrapper delegate-invoke) <Module>.invoke_void_object_NotifyCollectionChangedEventArgs (object,System.Collections.Specialized.NotifyCollectionChangedEventArgs) <IL 0x00027, 0x00042>
at System.Collections.ObjectModel.ObservableCollection`1<string>.OnCollectionChanged (System.Collections.Specialized.NotifyCollectionChangedEventArgs) <0x00081>
at System.Collections.ObjectModel.ObservableCollection`1<string>.ClearItems () <0x00091>
at System.Collections.ObjectModel.Collection`1<string>.Clear () <0x00028>
at AlcoholSales.VisitRecordPage.BuildUI (object,AlcoholSales.ViewModel.VisitRecordViewModel) [0x00013] in /Users/Michael/Google Drive/Gateway/Source/AlcoholSales/Pages/StoreVisits/VisitRecordPage.xaml.cs:43
at AlcoholSales.VisitRecordPage/<VisitRecordPage>c__AnonStorey0.<>m__0 () [0x00012] in /Users/Michael/Google Drive/Gateway/Source/AlcoholSales/Pages/StoreVisits/VisitRecordPage.xaml.cs:28
at Java.Lang.Thread/RunnableImplementor.Run () [0x0000b] in /Users/builder/data/lanes/monodroid-mlion-monodroid-4.20-series/ba9bbbdd/source/monodroid/src/Mono.Android/src/Java.Lang/Thread.cs:36
at Java.Lang.IRunnableInvoker.n_Run (intptr,intptr) [0x00009] in /Users/builder/data/lanes/monodroid-mlion-monodroid-4.20-series/ba9bbbdd/source/monodroid/src/Mono.Android/platforms/android-18/src/generated/Java.Lang.IRunnable.cs:71
at (wrapper dynamic-method) object.f74f69fb-d4f7-48fe-84a0-495dea2a12c8 (intptr,intptr) <IL 0x00011, 0x0001b>
Comment 2 Sadik Ali 2015-01-29 03:23:05 UTC
I have checked this issue with following steps given in comment (1) but I am not able to reproduce it.  
Screencast regarding same : http://www.screencast.com/t/laQfeEy7
Environment Info :
Forms :
=== Xamarin Studio ===

Version 5.7.1 (build 15)
Installation UUID: 67eaf3b4-f8a7-4ab4-a9df-3197350ca5dc
	Mono 3.12.0 ((detached/a813491)
	GTK+ 2.24.23 (Raleigh theme)

	Package version: 312000068

=== Apple Developer Tools ===

Xcode 6.2 (6758)
Build 6C107a

=== Xamarin.iOS ===

Version: (Enterprise Edition)
Hash: 3b3ef43
Build date: 2015-01-24 09:42:21-0500

=== Xamarin.Android ===

Version: (Enterprise Edition)
Android SDK: /Users/ixamarin78/Desktop/android-sdk-macosx
	Supported Android versions:
		2.1    (API level 7)
		2.2    (API level 8)
		2.3    (API level 10)
		3.1    (API level 12)
		4.0    (API level 14)
		4.0.3  (API level 15)
		4.1    (API level 16)
		4.2    (API level 17)
		4.3    (API level 18)
		4.4    (API level 19)
		4.4.87 (API level 20)
		5.0    (API level 21)
Java SDK: /usr
java version "1.8.0_25"
Java(TM) SE Runtime Environment (build 1.8.0_25-b17)
Java HotSpot(TM) 64-Bit Server VM (build 25.25-b02, mixed mode)

=== Xamarin.Mac ===

Version: (Enterprise Edition)

=== Build Information ===

Release ID: 507010015
Git revision: ce24e991948c7f3d88b0194a14fc1996d848ef51
Build date: 2015-01-26 16:42:20-05
Xamarin addins: 6895e3222bfa6910524708aa0633ff3db99bc3a0

=== Operating System ===

Mac OS X 10.10.0
Darwin XamnewiMac.local 14.0.0 Darwin Kernel Version 14.0.0
    Fri Sep 19 00:26:44 PDT 2014
    root:xnu-2782.1.97~2/RELEASE_X86_64 x86_64

Please let me know If I missed any step to reproduce this issue.
Comment 3 Michael Lane 2015-01-29 10:32:46 UTC
I am the customer who reported the bug. Based on the screen cast, you're not able to follow the steps I provided because there is no route data. When you select "Test Route A", you should see a grid with 6 entries appear below that. I'm not sure why this might be unless you encountered an exception when you tried to load route data from our web service. Could you please try again, and if you still don't see data when you select data from the picker, I will try to put together another sample that does not depend on our external web service.
Comment 4 Michael Lane 2015-01-29 10:44:45 UTC
Using the sample I provided, you will have the best experience on a 10" device in landscape mode. We have not optimized the experience for another device at this time.
Comment 5 Prashant Cholachagudda 2015-01-29 11:22:35 UTC
@Sadik I am sorry, I missed the point that you need to use 10" device/simulator to reproduce the issue. If you do not have device consider using Genymotion, they have 10" simulator.
Comment 6 Michael Lane 2015-01-29 11:39:03 UTC
Let me clarify, sorry. I do use Genymotion,with a simulated 10" screen in landscape mode. I do not think this will affect your ability to reproduce the bug, but it will make it easier for you to navigate to where you need to go (back and forth between pages) to get the bug to happen.
Comment 8 Jason Smith [MSFT] 2015-02-13 20:27:19 UTC
This should be fixed in 1.3.5-pre1