Bug 23172 - System.NullReferenceException in Xamarin.Forms.ListView
Summary: System.NullReferenceException in Xamarin.Forms.ListView
Status: RESOLVED FIXED
Alias: None
Product: Forms
Classification: Xamarin
Component: Forms ()
Version: 1.2.3
Hardware: PC Mac OS
: High normal
Target Milestone: ---
Assignee: Eric Maupin
URL:
Depends on:
Blocks:
 
Reported: 2014-09-18 22:02 UTC by Cody Beyer (MSFT)
Modified: 2015-05-29 16:14 UTC (History)
9 users (show)

Tags:
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:
Status:
RESOLVED FIXED

Description Cody Beyer (MSFT) 2014-09-18 22:02:56 UTC
The problem seems to be in the UpdateItems method of Xamarin.Forms.Platform.iOS.ListViewRenderer. I have strong evidence that it only happens under the following conditions:


1) A Xamarin.Forms.ListView is created

2) The ItemsSource property is set to an instance of a System.Collections.ObjectModel.ObservableCollection<object>

3) The ListView implements and ItemTemplate whose elements are bound to the properties of the elements in the observable collection

4) The ListView is returned by the overrided GetBody() method of a Xamarin.Forms.ContentPage

5) Everything works fine when:

a. Elements are added to the collection, or it is left empty, before the page is shown

b. The page is shown

c. Elements are added or removed WHILE the page is shown

6) The crash (see below) happens when:

a. Elements are added to the collection, or it is left empty, before the page is shown

b. The page is shown

c. Elements are added or removed, or not, with no problems

d. The page is hidden (another page is navigated to)

e. Elements are added or removed from the collection of the hidden page, and CRASH!

Here is what is happening:

Unhandled Exception: System.NullReferenceException: Object reference not set to an instance of an object

Thanks
Comment 2 Cody Beyer (MSFT) 2014-09-19 13:14:50 UTC
Also, another small detail. Then the page is shown again, modification of the collection still throws the exception. In other words, it’s not something that only happens when hidden; it happens after being shown and hidden, then still happens when shown again. I’m running the latest stable versions on both platforms. Here’s the version info:

Microsoft Visual Studio Premium 2013
Version 12.0.30723.00 Update 3
Microsoft .NET Framework
Version 4.5.50938

Installed Version: Premium

LightSwitch for Visual Studio 2013 06191-004-0456024-02610
Microsoft LightSwitch for Visual Studio 2013

Team Explorer for Visual Studio 2013 06191-004-0456024-02610
Microsoft Team Explorer for Visual Studio 2013

Visual Basic 2013 06191-004-0456024-02610
Microsoft Visual Basic 2013

Visual C# 2013 06191-004-0456024-02610
Microsoft Visual C# 2013

Visual C++ 2013 06191-004-0456024-02610
Microsoft Visual C++ 2013

Visual F# 2013 06191-004-0456024-02610
Microsoft Visual F# 2013

Visual Studio 2013 Code Analysis Spell Checker 06191-004-0456024-02610
Microsoft® Visual Studio® 2013 Code Analysis Spell Checker

Portions of International CorrectSpell™ spelling correction system © 1993 by Lernout & Hauspie Speech Products N.V. All rights reserved.

The American Heritage® Dictionary of the English Language, Third Edition Copyright © 1992 Houghton Mifflin Company. Electronic version licensed from Lernout & Hauspie Speech Products N.V. All rights reserved.

Application Insights Tools for Visual Studio Package 1.0
Application Insights Tools for Visual Studio

ASP.NET and Web Tools 12.3.50717.0
Microsoft Web Developer Tools contains the following components:
Support for creating and opening ASP.NET web projects
Browser Link: A communication channel between Visual Studio and browsers
Editor extensions for HTML, CSS, and JavaScript
Page Inspector: Inspection tool for ASP.NET web projects
Scaffolding: A framework for building and running code generators
Server Explorer extensions for Microsoft Azure Websites
Web publishing: Extensions for publishing ASP.NET web projects to hosting providers, on-premises servers, or Microsoft Azure

ASP.NET Web Frameworks and Tools 2012.2 4.1.21001.0
For additional information, visit http://go.microsoft.com/fwlink/?LinkID=309563

ASP.NET Web Frameworks and Tools 2013 5.2.20703.0
For additional information, visit http://www.asp.net/

Common Azure Tools 1.2
Provides common services for use by Azure Mobile Services and Microsoft Azure Tools.

Microsoft Azure Mobile Services Tools 1.2
Microsoft Azure Mobile Services Tools

NuGet Package Manager 2.8.50313.46
NuGet Package Manager in Visual Studio. For more information about NuGet, visit http://docs.nuget.org/.

Office Developer Tools for Visual Studio 2013 ENU 12.0.30626
Microsoft Office Developer Tools for Visual Studio 2013 ENU

PowerShell Tools 1.2
Provides file classification services using PowerShell

PreEmptive Analytics Visualizer 1.2
Microsoft Visual Studio extension to visualize aggregated summaries from the PreEmptive Analytics product.

SQL Server Data Tools 12.0.30919.1
Microsoft SQL Server Data Tools

VisualSVN 4.0.2
Integration with Subversion version control. For more information about VisualSVN, see the VisualSVN website at http://www.visualsvn.com
Copyright © 2005-2013 VisualSVN Ltd. All rights reserved.

Windows Azure Remote Debugging 1.0
Windows Azure Remote Debugging Community Technology Preview

Windows Azure Tools 2.2
Windows Azure Tools for Microsoft Visual Studio 2013 - v2.2.11003.1601

Windows Phone 8.1 SDK Integration 1.0
This package integrates the tools for the Windows Phone 8.1 SDK into the menus and controls of Visual Studio.

Workflow Manager Tools 1.0 1.0
This package contains the necessary Visual Studio integration components for Workflow Manager.

Xamarin 3.5.58.0 (6b70b1e28c5a733187f7659220da4c0ff61ab2b1)
Visual Studio extension to enable development for Xamarin.iOS and Xamarin.Android
Comment 3 Eric Maupin 2014-09-23 00:49:14 UTC
I attempted to create a reproduction with the given information, but was unable to replicate the problem.

Can you provide a small test case that demonstrates the issue?
Comment 5 Eric Maupin 2015-05-18 19:19:58 UTC
The linked sample app is currently a 404.
Comment 7 Eric Maupin 2015-05-29 16:14:37 UTC
This appears to be fixed in the current version.