Bug 36955 - [iOS] ViewCellRenderer.UpdateIsEnabled Object reference not set to an instance of an object
Summary: [iOS] ViewCellRenderer.UpdateIsEnabled Object reference not set to an instanc...
Status: VERIFIED FIXED
Alias: None
Product: Forms
Classification: Xamarin
Component: Forms ()
Version: 2.1.0
Hardware: PC Windows
: Normal major
Target Milestone: ---
Assignee: Bugzilla
URL:
: 37028 ()
Depends on:
Blocks:
 
Reported: 2015-12-14 01:37 UTC by Adam
Modified: 2016-11-10 00:30 UTC (History)
13 users (show)

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


Attachments
WorkingSample (67.82 KB, application/zip)
2016-03-30 18:09 UTC, Matthew Regul
Details
Sample to reproduce the issue (142.64 KB, application/x-zip-compressed)
2016-03-30 18:50 UTC, aer127
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:
VERIFIED FIXED

Description Adam 2015-12-14 01:37:06 UTC
When setting the IsEnabled property of a custom ViewCell which had a toggle/switch and label defined in it, I would receive the error

System.NullReferenceExceptionObject reference not set to an instance of an object
Raw
Xamarin.Forms.Platform.iOS.ViewCellRenderer.UpdateIsEnabled(ViewTableCell cell, ViewCell viewCell)
Xamarin.Forms.Platform.iOS.ViewCellRenderer.ViewCellPropertyChanged(object sender, PropertyChangedEventArgs e)
Xamarin.Forms.BindableObject.OnPropertyChanged(string propertyName)
Xamarin.Forms.BindableObject.SetValueActual(BindableProperty property, BindablePropertyContext context, object value, bool currentlyApplying, SetValueFlags attributes, bool silent)
Xamarin.Forms.BindableObject.SetValueCore(BindableProperty property, object value, SetValueFlags attributes, SetValuePrivateFlags privateAttributes)
Xamarin.Forms.BindingExpression.ApplyCore(object sourceObject, BindableObject target, BindableProperty property, bool fromTarget)
Xamarin.Forms.BindingExpression.Apply(bool fromTarget)
Xamarin.Forms.BindingExpression.BindingExpressionPart.<PropertyChanged>b__38_0()
Foundation.NSAsyncActionDispatcher.Apply()NSAction.cs:163
UIKit.UIApplication.UIApplicationMain(int, string[], intptr, intptr)(wrapper managed-to-native)
UIKit.UIApplication.Main(string[] args, IntPtr principal, IntPtr delegate)UIApplication.cs:77
UIKit.UIApplication.Main(string[] args, string principalClassName, string delegateClassName)UIApplication.cs:60
HIPS.Mobile.iOS.Application.Main(string[] args)

Happens on iOS only. Rogier also experienced this bug starting from 1.4.3 - https://forums.xamarin.com/discussion/44648/xamarin-forms-1-4-3-released/p3
Comment 1 brandon21486 2016-01-15 20:18:12 UTC
Getting the same error when trying to set a ViewCell's IsEnabled after data is entered on another field.

2016-01-15 13:44:44.078 MyMobileAppiOS[87782:19727632] 
Unhandled Exception:
System.NullReferenceException: Object reference not set to an instance of an object
  at Xamarin.Forms.Platform.iOS.ViewCellRenderer.UpdateIsEnabled (Xamarin.Forms.Platform.iOS.ViewTableCell cell, Xamarin.Forms.ViewCell viewCell) [0x00007] in <filename unknown>:0 
  at Xamarin.Forms.Platform.iOS.ViewCellRenderer.ViewCellPropertyChanged (System.Object sender, System.ComponentModel.PropertyChangedEventArgs e) [0x0002a] in <filename unknown>:0 
  at (wrapper delegate-invoke) <Module>:invoke_void_object_PropertyChangedEventArgs (object,System.ComponentModel.PropertyChangedEventArgs)
  at Xamarin.Forms.BindableObject.OnPropertyChanged (System.String propertyName) [0x00012] in <filename unknown>:0 
  at Xamarin.Forms.BindableObject.SetValueActual (Xamarin.Forms.BindableProperty property, Xamarin.Forms.BindablePropertyContext context, System.Object value, Boolean currentlyApplying, SetValueFlags attributes, Boolean silent) [0x0
00fb] in <filename unknown>:0 
  at Xamarin.Forms.BindableObject.SetValueCore (Xamarin.Forms.BindableProperty property, System.Object value, SetValueFlags attributes, SetValuePrivateFlags privateAttributes) [0x0014b] in <filename unknown>:0 
  at Xamarin.Forms.BindingExpression.ApplyCore (System.Object sourceObject, Xamarin.Forms.BindableObject target, Xamarin.Forms.BindableProperty property, Boolean fromTarget) [0x0020b] in <filename unknown>:0 
  at Xamarin.Forms.BindingExpression.Apply (Boolean fromTarget) [0x0003e] in <filename unknown>:0 
  at Xamarin.Forms.BindingExpression+BindingExpressionPart.<PropertyChanged>b__38_0 () [0x00000] in <filename unknown>:0 
  at Foundation.NSAsyncActionDispatcher.Apply () [0x00000] in /Users/builder/data/lanes/2377/73229919/source/maccore/src/Foundation/NSAction.cs:163 
  at (wrapper managed-to-native) UIKit.UIApplication:UIApplicationMain (int,string[],intptr,intptr)
  at UIKit.UIApplication.Main (System.String[] args, IntPtr principal, IntPtr delegate) [0x00005] in /U
sers/builder/data/lanes/2377/73229919/source/maccore/src/UIKit/UIApplication.cs:77 
  at UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x00038] in /Users/builder/data/lanes/2377/73229919/source/maccore/src/UIKit/UIApplication.cs:61 
  at MyMobileApp.iOS.Application.Main (System.String[] args) [0x0000d] in C:\Source\XamarinApps\MyMobileApp\MyMobileApp\MyMobileApp.iOS\Main.cs:24 
2016-01-15 13:44:44.078 MyMobileAppiOS[87782:19727632] Unhandled managed exception:
Object reference not set to an instance of an object (System.NullReferenceException)
  at Xamarin.Forms.Platform.iOS.ViewCellRenderer.UpdateIsEnabled (Xamarin.Forms.Platform.iOS.ViewTableCell cell, Xamarin.Forms.ViewCell viewCell) [0x00007] in <filename unknown>:0 
  at Xamarin.Forms.Platform.iOS.ViewCellRenderer.ViewCellPropertyChanged (System.Object sender, System.ComponentModel.PropertyChangedEventArgs e) [0x0002a] in
 <filename unknown>:0 
  at (wrapper delegate-invoke) <Module>:invoke_void_object_PropertyChangedEventArgs (object,System.ComponentModel.PropertyChangedEventArgs)
  at Xamarin.Forms.BindableObject.OnPropertyChanged (System.String propertyName) [0x00012] in <filename unknown>:0 
  at Xamarin.Forms.BindableObject.SetValueActual (Xamarin.Forms.BindableProperty property, Xamarin.Forms.BindablePropertyContext context, System.Object value, Boolean currentlyApplying, SetValueFlags attributes, Boolean silent) [0x000fb] in <filename unknown>:0 
  at Xamarin.Forms.BindableObject.SetValueCore (Xamarin.Forms.BindableProperty property, System.Object value, SetValueFlags attributes, SetValuePrivateFlags privateAttributes) [0x0014b] in <filename unknown>:0 
  at Xamarin.Forms.BindingExpression.ApplyCore (System.Object sourceObject, Xamarin.Forms.BindableObject target, Xamarin.Forms.BindableProperty property, Boolean fromTarget) [0x0020b] in <filename unknown>:0 
  at Xamarin.Forms.BindingExpression.Apply (Boolean fromTarget
) [0x0003e] in <filename unknown>:0 
  at Xamarin.Forms.BindingExpression+BindingExpressionPart.<PropertyChanged>b__38_0 () [0x00000] in <filename unknown>:0 
  at Foundation.NSAsyncActionDispatcher.Apply () [0x00000] in /Users/builder/data/lanes/2377/73229919/source/maccore/src/Foundation/NSAction.cs:163 
  at (wrapper managed-to-native) UIKit.UIApplication:UIApplicationMain (int,string[],intptr,intptr)
  at UIKit.UIApplication.Main (System.String[] args, IntPtr principal, IntPtr delegate) [0x00005] in /Users/builder/data/lanes/2377/73229919/source/maccore/src/UIKit/UIApplication.cs:77 
  at UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x00038] in /Users/builder/data/lanes/2377/73229919/source/maccore/src/UIKit/UIApplication.cs:61 
  at MyMobileApp.iOS.Application.Main (System.String[] args) [0x0000d] in C:\Source\XamarinApps\MyMobileApp\MyMobileApp\MyMobileApp.iOS\Main.cs:24
Comment 2 Jacob 2016-02-05 10:07:14 UTC
Same error happens in my newly created project.

I have about 5-7 cells in a TableView with entry fields.

I want to set IsEnabled on all ViewCells when user is submitting the values and we are waiting for a server response.

But setting the ViewCell's IsEnabled property cause my app to throw this: 

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

  at Xamarin.Forms.Platform.iOS.ViewCellRenderer.UpdateIsEnabled (Xamarin.Forms.Platform.iOS.ViewTableCell cell, Xamarin.Forms.ViewCell viewCell) [0x00007] in <filename unknown>:0

  at Xamarin.Forms.Platform.iOS.ViewCellRenderer.ViewCellPropertyChanged (System.Object sender, System.ComponentModel.PropertyChangedEventArgs e) [0x0002a] in <filename unknown>:0

  at Xamarin.Forms.BindableObject.OnPropertyChanged (System.String propertyName) [0x00012] in <filename unknown>:0

  at Xamarin.Forms.BindableObject.SetValueActual (Xamarin.Forms.BindableProperty property, Xamarin.Forms.BindablePropertyContext context, System.Object value, Boolean currentlyApplying, SetValueFlags attributes, Boolean silent) [0x000fb] in <filename unknown>:0

  at Xamarin.Forms.BindableObject.SetValueCore (Xamarin.Forms.BindableProperty property, System.Object value, SetValueFlags attributes, SetValuePrivateFlags privateAttributes) [0x0014b] in <filename unknown>:0

  at Xamarin.Forms.BindableObject.SetValue (Xamarin.Forms.BindableProperty property, System.Object value, Boolean fromStyle, Boolean checkAccess) [0x0005f] in <filename unknown>:0

  at Xamarin.Forms.BindableObject.SetValue (Xamarin.Forms.BindableProperty property, System.Object value) [0x00000] in <filename unknown>:0

  at Xamarin.Forms.Cell.set_IsEnabled (Boolean value) [0x00000] in <filename unknown>:0

  at MyApp.NewTimesheetEntryPage.DisableUI () [0x00014] in /Users/MyUserName/Projects/MyApp/MyApp/Pages/Timesheet/NewTimesheetEntryPage.xaml.cs:388

  at MyApp.NewTimesheetEntryPage+<SendTimeEntry>c__async0.MoveNext () [0x00045] in /Users/MyUserName/Projects/MyApp/MyApp/Pages/Timesheet/NewTimesheetEntryPage.xaml.cs:154

  at --- End of stack trace from previous location where exception was thrown ---

  at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in /Users/builder/data/lanes/2689/962a0506/source/maccore/_build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/src/mono/external/referencesource/mscorlib/system/runtime/exceptionservices/exceptionservicescommon.cs:143

  at System.Runtime.CompilerServices.AsyncMethodBuilderCore.<ThrowAsync>m__0 (System.Object state) [0x00000] in /Users/builder/data/lanes/2689/962a0506/source/maccore/_build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/src/mono/external/referencesource/mscorlib/system/runtime/compilerservices/AsyncMethodBuilder.cs:994

  at UIKit.UIKitSynchronizationContext+<Post>c__AnonStorey0.<>m__0 () [0x00000] in /Users/builder/data/lanes/2689/962a0506/source/maccore/src/UIKit/UIKitSynchronizationContext.cs:24

  at Foundation.NSAsyncActionDispatcher.Apply () [0x00000] in /Users/builder/data/lanes/2689/962a0506/source/maccore/src/Foundation/NSAction.cs:163

  at at (wrapper managed-to-native) UIKit.UIApplication:UIApplicationMain (int,string[],intptr,intptr)

  at UIKit.UIApplication.Main (System.String[] args, IntPtr principal, IntPtr delegate) [0x00005] in /Users/builder/data/lanes/2689/962a0506/source/maccore/src/UIKit/UIApplication.cs:77

  at UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x00038] in /Users/builder/data/lanes/2689/962a0506/source/maccore/src/UIKit/UIApplication.cs:61

  at MyApp.iOS.Application.Main (System.String[] args) [0x00008] in /Users/MyUserName/Projects/MyApp/iOS/Main.cs:17
Comment 3 aer127 2016-03-29 12:01:41 UTC
I too am having this same issue. Can someone from Xamarin please acknowledge the issue and let us know a workaround or when to expect a fix?
Comment 4 Matthew Regul 2016-03-30 18:09:17 UTC
Created attachment 15561 [details]
WorkingSample

Hello, I was unable to reproduce the issue, could someone please provide a sample that demonstrates the issue?

Attached is a copy of my sample app

===========

I suppose a workaround could be to set each of the individual control's isEnabled to false, and not the parent container?
Comment 5 Matthew Regul 2016-03-30 18:19:26 UTC
Related Post - http://forums.xamarin.com/discussion/comment/175385
Comment 6 aer127 2016-03-30 18:50:13 UTC
Created attachment 15562 [details]
Sample to reproduce the issue

To reproduce the crash, simply flip the switch in the SwitchCell in the sample.
Comment 7 Jason Smith [MSFT] 2016-04-07 05:57:49 UTC
Should be fixed in 2.3.0-pre1
Comment 8 Rajneesh Kumar 2016-05-10 18:29:29 UTC
I have checked this issue with the XF 2.3.0.38-pre2 and observed that this issue has been fixed and no longer exist with this version of XF. Now user os able to flip the switch in the SwitchCell in the attached test sample provided in comment 6.

Screencast: http://www.screencast.com/t/NynpvM9nuY

This issue has been fixed, hence I am closing this issue.

Thanks..!
Comment 9 E.Z. Hart [MSFT] 2016-11-10 00:30:03 UTC
*** Bug 37028 has been marked as a duplicate of this bug. ***