You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
NullReferenceException at BindingExpression #32602
System.NullReferenceException:Object reference not set to an instance of an object at Microsoft.Maui.Controls.WeakEventProxy2[[System.ComponentModel.INotifyPropertyChanged, System.ObjectModel, Version=9.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a],[System.ComponentModel.PropertyChangedEventHandler, System.ObjectModel, Version=9.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a]].TryGetHandler(PropertyChangedEventHandler& )
at Microsoft.Maui.Controls.BindingExpression.WeakPropertyChangedProxy.OnPropertyChanged(Object sender, PropertyChangedEventArgs e)
at SomeViewModel.SomeProperty.OnPropertyChanged(String propertyName)`
No. I've only seen this error a couple of times in the production app log(rare). Last time the property was bound to CollectionView.SelectedItem. Property updated in non UI thread.
Exception from Sentry:
System.NullReferenceException: Object reference not set to an instance of an object
at bool WeakEventProxy<INotifyPropertyChanged, PropertyChangedEventHandler>.TryGetSource(out INotifyPropertyChanged source)() in WeakEventProxy.cs:line 27
at void WeakPropertyChangedProxy.Unsubscribe()() in BindingExpression.cs:line 602
at void WeakPropertyChangedProxy.OnPropertyChanged(object sender, PropertyChangedEventArgs e)() in BindingExpression.cs:line 615
at void BindableObject.OnPropertyChanged(string propertyName)() in BindableObject.cs:line 408
at void Element.OnPropertyChanged(string propertyName)() in Element.cs:line 691
at void BindableObject.OnBindablePropertySet(BindableProperty property, object original, object value, bool didChange, bool willFirePropertyChanged)() in BindableObject.cs:line 675
at void Element.OnBindablePropertySet(BindableProperty property, object original, object value, bool changed, bool willFirePropertyChanged)() in Element.cs:line 668
at void BindableObject.SetValueActual(BindableProperty property, BindablePropertyContext context, object value, bool currentlyApplying, SetValueFlags attributes, SetterSpecificity specificity, bool silent)() in BindableObject.cs:line 663
at void BindableObject.SetValueCore(BindableProperty property, object value, SetValueFlags attributes, SetValuePrivateFlags privateAttributes, SetterSpecificity specificity)() in BindableObject.cs:line 591
at void TypedBinding<IChargeDetailsViewModel, Patient>.ApplyCore(object sourceObject, BindableObject target, BindableProperty property, bool fromTarget, SetterSpecificity specificity)() in TypedBinding.cs:line 325
at void TypedBinding<IChargeDetailsViewModel, Patient>.ApplyToResolvedSource(object source, BindableObject target, BindableProperty targetProperty, bool fromBindingContextChanged, SetterSpecificity specificity)() in TypedBinding.cs:line 248
at void TypedBinding<IChargeDetailsViewModel, Patient>.Apply(object context, BindableObject bindObj, BindableProperty targetProperty, bool fromBindingContextChanged, SetterSpecificity specificity)() in TypedBinding.cs:line 199
at void BindableObject.ApplyBindings(bool fromBindingContextChanged)() in BindableObject.cs:line 693
at void BindableObject.SetInheritedBindingContext(BindableObject bindable, object value)() in BindableObject.cs:line 367
at void Element.SetChildInheritedBindingContext(Element child, object context)() in Element.cs:line 827
at void Element.OnBindingContextChanged()+(BindableObject child, object bc) => { }() in Element.cs:line 603
at void BindableObjectExtensions.PropagateBindingContext(BindableObject self, IEnumerable children, Action<BindableObject, object> setChildBindingContext)() in BindableObjectExtensions.cs:line 48
at void Element.OnBindingContextChanged()() in Element.cs:line 601
at void VisualElement.OnBindingContextChanged()() in VisualElement.cs:line 1366
at void View.OnBindingContextChanged()() in View.cs:line 263
at void BindableObject.SetInheritedBindingContext(BindableObject bindable, object value)() in BindableObject.cs:line 368
at void Element.SetChildInheritedBindingContext(Element child, object context)() in Element.cs:line 827
at void Element.SetParent(Element value)() in Element.cs:line 432
at void Element.OnChildAdded(Element child)() in Element.cs:line 620
at void VisualElement.OnChildAdded(Element child)() in VisualElement.cs:line 1375
at void Element.AddLogicalChild(Element element)() in Element.cs:line 225
at void Layout.Add(IView child)() in Layout.cs:line 163
at void ChargeDetailsPage.InitializeComponent()() in Views_Hospital_ChargeDetailsPage.xaml.sg.cs:line 35
at new ChargeDetailsPage(ChargeDetailsParameter parameter, IChargeDetailsViewModel chargeDetailsViewModel, IMessenger messenger, ISecurityService securityService, IXamarinForms xamarinForms)() in ChargeDetailsPage.xaml.cs:line 33
at object ConstructorInvoker.InterpretedInvoke(object obj, IntPtr* args)()
at object ConstructorInvoker.InvokeWithManyArgs(Span)()
at object ConstructorInvoker.Invoke(Span)()
at object ConstructorMatcher.CreateInstance(IServiceProvider)()
at object ActivatorUtilities.CreateInstance(IServiceProvider, Type, params object[])()
at ChargeDetailsPage ActivatorUtilities.CreateInstance(IServiceProvider, params object[])()
at async Task NavigationService.ToChargeDetails(string hospitalStayId, string chargeId, bool makeCopy, bool animate, ENavigationType navigationType)() in NavigationService.cs:line 217
at async void AsyncRelayCommand.AwaitAndThrowIfFailed(Task)() in AsyncRelayCommand.cs:line 351
at void Task.ThrowAsync(Exception, SynchronizationContext)+(object state) => { }()
at void NSAsyncSynchronizationContextDispatcher.Apply()() in NSAction.cs:line 167
at void Registrar_Callbacks.callback_4248_Foundation_NSAsyncSynchronizationContextDispatcher_Apply(IntPtr pobj, IntPtr sel, IntPtr* exception_gchandle)()
Suspect this is due to having Fody.PropertyChanged in my project. Seeing if excluding a databound ContentView from PropertyChanged-weaving fixes the issue
We are still seeing the same underlying WeakEventProxy race in production on .NET MAUI 10.
Our Android application uses Microsoft.Maui.Controls 10.0.90 and .NET runtime 10.0.11. This Sentry issue has 167 occurrences affecting 30 users; the latest occurrence was on Android 16 (API 36). There are no application frames in the stack trace:
System.NullReferenceException
at WeakEventProxy<INotifyPropertyChanged, PropertyChangedEventHandler>.TryGetSource(...)
at WeakPropertyChangedProxy.Unsubscribe()
at BindingExpressionPart.Finalize()
This strongly suggests the same field-read race described here, but on _source during finalization/unsubscription rather than on _handler while handling PropertyChanged. Unsubscribe() sets _source and _handler to null; another concurrent path can therefore observe a non-null field in the condition and then dereference it after it has been cleared.
The current main branch still has this pattern in both methods:
if(_sourceis not null&&_source.TryGetTarget(outsource))
A minimal defensive fix is to capture the weak-reference field once before testing it (and apply the same change to TryGetHandler):
publicboolTryGetSource([MaybeNullWhen(false)]outTSourcesource){varsourceReference=_source;if(sourceReferenceis not null&&sourceReference.TryGetTarget(outsource)){returnsourceis not null;}source=default;returnfalse;}publicboolTryGetHandler([MaybeNullWhen(false)]outTEventHandlerhandler){varhandlerReference=_handler;if(handlerReferenceis not null&&handlerReference.TryGetTarget(outhandler)){returnhandleris not null;}handler=default;returnfalse;}
This removes the time-of-check/time-of-use window without changing the existing weak-event semantics. Since this can occur from a finalizer, it is an unhandled process-terminating crash on Android rather than a recoverable binding error.
Thank you for the report and the investigation details. We are closing this as completed: WeakEventProxy captures its source and handler before checking and dereferencing them, removing the exact BindingExpression null-reference race. This records the inflight/current repair, not a claim that every package contains it.
Supporting evidence: #37568 (merged into inflight/current).
This records the merged source change; it does not imply that the fix is present in every released .NET MAUI package.
If you can still reproduce the reported behavior in a build that includes the linked change, please comment here with the exact version and reproduction details so we can reopen and investigate. The existing reproduction and discussion remain available; a new issue is not required.
Activity
StephaneDelcroix commentedon Nov 14, 2025
do you have a reproduction project ?
Toomas75 commentedon Nov 18, 2025
No. I've only seen this error a couple of times in the production app log(rare). Last time the property was bound to CollectionView.SelectedItem. Property updated in non UI thread.
Can't reproduce myself. But it happens.
MichaelLHerman commentedon Jun 2, 2026
Seeing this in 9.0.120
Don't have a minimally reproducible sample
Exception from Sentry:
System.NullReferenceException: Object reference not set to an instance of an object
at bool WeakEventProxy<INotifyPropertyChanged, PropertyChangedEventHandler>.TryGetSource(out INotifyPropertyChanged source)() in WeakEventProxy.cs:line 27
at void WeakPropertyChangedProxy.Unsubscribe()() in BindingExpression.cs:line 602
at void WeakPropertyChangedProxy.OnPropertyChanged(object sender, PropertyChangedEventArgs e)() in BindingExpression.cs:line 615
at void BindableObject.OnPropertyChanged(string propertyName)() in BindableObject.cs:line 408
at void Element.OnPropertyChanged(string propertyName)() in Element.cs:line 691
at void BindableObject.OnBindablePropertySet(BindableProperty property, object original, object value, bool didChange, bool willFirePropertyChanged)() in BindableObject.cs:line 675
at void Element.OnBindablePropertySet(BindableProperty property, object original, object value, bool changed, bool willFirePropertyChanged)() in Element.cs:line 668
at void BindableObject.SetValueActual(BindableProperty property, BindablePropertyContext context, object value, bool currentlyApplying, SetValueFlags attributes, SetterSpecificity specificity, bool silent)() in BindableObject.cs:line 663
at void BindableObject.SetValueCore(BindableProperty property, object value, SetValueFlags attributes, SetValuePrivateFlags privateAttributes, SetterSpecificity specificity)() in BindableObject.cs:line 591
at void TypedBinding<IChargeDetailsViewModel, Patient>.ApplyCore(object sourceObject, BindableObject target, BindableProperty property, bool fromTarget, SetterSpecificity specificity)() in TypedBinding.cs:line 325
at void TypedBinding<IChargeDetailsViewModel, Patient>.ApplyToResolvedSource(object source, BindableObject target, BindableProperty targetProperty, bool fromBindingContextChanged, SetterSpecificity specificity)() in TypedBinding.cs:line 248
at void TypedBinding<IChargeDetailsViewModel, Patient>.Apply(object context, BindableObject bindObj, BindableProperty targetProperty, bool fromBindingContextChanged, SetterSpecificity specificity)() in TypedBinding.cs:line 199
at void BindableObject.ApplyBindings(bool fromBindingContextChanged)() in BindableObject.cs:line 693
at void BindableObject.SetInheritedBindingContext(BindableObject bindable, object value)() in BindableObject.cs:line 367
at void Element.SetChildInheritedBindingContext(Element child, object context)() in Element.cs:line 827
at void Element.OnBindingContextChanged()+(BindableObject child, object bc) => { }() in Element.cs:line 603
at void BindableObjectExtensions.PropagateBindingContext(BindableObject self, IEnumerable children, Action<BindableObject, object> setChildBindingContext)() in BindableObjectExtensions.cs:line 48
at void Element.OnBindingContextChanged()() in Element.cs:line 601
at void VisualElement.OnBindingContextChanged()() in VisualElement.cs:line 1366
at void View.OnBindingContextChanged()() in View.cs:line 263
at void BindableObject.SetInheritedBindingContext(BindableObject bindable, object value)() in BindableObject.cs:line 368
at void Element.SetChildInheritedBindingContext(Element child, object context)() in Element.cs:line 827
at void Element.SetParent(Element value)() in Element.cs:line 432
at void Element.OnChildAdded(Element child)() in Element.cs:line 620
at void VisualElement.OnChildAdded(Element child)() in VisualElement.cs:line 1375
at void Element.AddLogicalChild(Element element)() in Element.cs:line 225
at void Layout.Add(IView child)() in Layout.cs:line 163
at void ChargeDetailsPage.InitializeComponent()() in Views_Hospital_ChargeDetailsPage.xaml.sg.cs:line 35
at new ChargeDetailsPage(ChargeDetailsParameter parameter, IChargeDetailsViewModel chargeDetailsViewModel, IMessenger messenger, ISecurityService securityService, IXamarinForms xamarinForms)() in ChargeDetailsPage.xaml.cs:line 33
at object ConstructorInvoker.InterpretedInvoke(object obj, IntPtr* args)()
at object ConstructorInvoker.InvokeWithManyArgs(Span)()
at object ConstructorInvoker.Invoke(Span)()
at object ConstructorMatcher.CreateInstance(IServiceProvider)()
at object ActivatorUtilities.CreateInstance(IServiceProvider, Type, params object[])()
at ChargeDetailsPage ActivatorUtilities.CreateInstance(IServiceProvider, params object[])()
at async Task NavigationService.ToChargeDetails(string hospitalStayId, string chargeId, bool makeCopy, bool animate, ENavigationType navigationType)() in NavigationService.cs:line 217
at async void AsyncRelayCommand.AwaitAndThrowIfFailed(Task)() in AsyncRelayCommand.cs:line 351
at void Task.ThrowAsync(Exception, SynchronizationContext)+(object state) => { }()
at void NSAsyncSynchronizationContextDispatcher.Apply()() in NSAction.cs:line 167
at void Registrar_Callbacks.callback_4248_Foundation_NSAsyncSynchronizationContextDispatcher_Apply(IntPtr pobj, IntPtr sel, IntPtr* exception_gchandle)()
Suspect this is due to having Fody.PropertyChanged in my project. Seeing if excluding a databound ContentView from PropertyChanged-weaving fixes the issue
baaaaif commentedon Aug 18, 2026
We are still seeing the same underlying
WeakEventProxyrace in production on .NET MAUI 10.Our Android application uses
Microsoft.Maui.Controls10.0.90 and .NET runtime 10.0.11. This Sentry issue has 167 occurrences affecting 30 users; the latest occurrence was on Android 16 (API 36). There are no application frames in the stack trace:This strongly suggests the same field-read race described here, but on
_sourceduring finalization/unsubscription rather than on_handlerwhile handlingPropertyChanged.Unsubscribe()sets_sourceand_handlertonull; another concurrent path can therefore observe a non-null field in the condition and then dereference it after it has been cleared.The current
mainbranch still has this pattern in both methods:A minimal defensive fix is to capture the weak-reference field once before testing it (and apply the same change to
TryGetHandler):This removes the time-of-check/time-of-use window without changing the existing weak-event semantics. Since this can occur from a finalizer, it is an unhandled process-terminating crash on Android rather than a recoverable binding error.
Fix race in WeakEventProxy field access (#37568)
13 remaining items
Fix race in WeakEventProxy field access (#37568)
Fix race in WeakEventProxy field access (#37568)
Fix race in WeakEventProxy field access (#37568)
Fix race in WeakEventProxy field access (#37568)
Fix race in WeakEventProxy field access (#37568)
Fix race in WeakEventProxy field access (#37568)
kubaflo commentedon Oct 10, 2026
Thank you for the report and the investigation details. We are closing this as completed: WeakEventProxy captures its source and handler before checking and dereferencing them, removing the exact BindingExpression null-reference race. This records the inflight/current repair, not a claim that every package contains it.
Supporting evidence: #37568 (merged into
inflight/current).This records the merged source change; it does not imply that the fix is present in every released .NET MAUI package.
If you can still reproduce the reported behavior in a build that includes the linked change, please comment here with the exact version and reproduction details so we can reopen and investigate. The existing reproduction and discussion remain available; a new issue is not required.
Fix race in WeakEventProxy field access (#37568)
Fix race in WeakEventProxy field access (#37568)
Fix race in WeakEventProxy field access (#37568)
Fix race in WeakEventProxy field access (#37568)
Fix race in WeakEventProxy field access (#37568)
Fix race in WeakEventProxy field access (#37568)