Caliburn-Micro / Caliburn.Micro

A small, yet powerful framework, designed for building applications across all XAML platforms. Its strong support for MV* patterns will enable you to build your solution quickly, without the need to sacrifice code quality or testability.
http://caliburnmicro.com/
MIT License
2.79k stars 776 forks source link

Occassional NullReferenceException when Caliburn applies action conventions #821

Open NikolaR opened 2 years ago

NikolaR commented 2 years ago

Very sparingly it happens that my application has unexpected behavior, which happens during application startup. Looking at the log files, apparently during convention application.

Caliburn version: 4.0.173 .NET Framework: 4.7.1

I'm not able to make a reproduction of it because it happens very rarely. It had happened once in few weeks. Process does not crash, application UI does not freeze per se (progress indicator keeps spinning), there is no CPU usage, but initialization of the application is not complete.

Best I could identify the culprit (based on log below) it is following:

<Button Content="xxxxxxx" x:Name="ImportPamsLicense" AutomationProperties.AutomationId="Button_ImportPamsLicense" Visibility="xxxxxxxx" /> binding to async void method in ViewModel public async void ImportPamsLicense() { ....... }

Exception occurs when first Action Convention is applied. There are previous conventions not applied, but fails on first one that is (or rather that should be applied).

66000|2022-08-15 11:04:56.9387|TRACE||App|Initializing NBug reports folder regarding NLog logging folder. 66000|2022-08-15 11:04:56.9600|TRACE||App|Initializing NBug reports folder to 'C:\Users\lmbran0\AppData\Local\Liebherr_Machines_Bulle\LIDIA\logs'. 66000|2022-08-15 11:04:56.9600|INFO||App|NBug reports folder initialized successfully (C:\Users\lmbran0\AppData\Local\Liebherr_Machines_Bulle\LIDIA\logs). 66000|2022-08-15 11:04:56.9600|INFO||App|Checking NBug reports (StoragePath.Custom) in C:\Users\lmbran0\AppData\Local\Liebherr_Machines_Bulle\LIDIA\logs 66000|2022-08-15 11:04:56.9920|INFO||LiobaWpfBootstrapper|Starting application. 66000|2022-08-15 11:04:56.9920|INFO||LiobaWpfBootstrapper| CLR version 4.0.30319.42000 66000|2022-08-15 11:04:57.0092|DEBUG||LidiaBootstrapper|Logger was created successfully. 66000|2022-08-15 11:04:57.0092|DEBUG||LidiaBootstrapper|Creating Unity container. 66000|2022-08-15 11:04:57.0092|DEBUG||LidiaBootstrapper|Configuring the Unity container. 66000|2022-08-15 11:04:57.2349|DEBUG||LiobaWpfBootstrapper|Registering services based on conventions... 66000|2022-08-15 11:04:58.3176|DEBUG||LiobaWpfBootstrapper|Finished registering services based on conventions. 66000|2022-08-15 11:04:58.4104|DEBUG||LidiaBootstrapper|Bootstrapper sequence completed. 66000|2022-08-15 11:05:00.3310|DEBUG||LidiaBootstrapper|Configuring Custom Type Descriptors. 66000|2022-08-15 11:05:00.3310|DEBUG||LidiaBootstrapper|Custom Type Descriptors configuration completed. 66000|2022-08-15 11:05:01.2316|INFO||LidiaProductInformation|Product version: 1.0.0.0 66000|2022-08-15 11:05:01.5760|INFO||LidiaProductInformation|Product version: 1.0.0.0 66000|2022-08-15 11:05:02.2377|TRACE||CaliburnLogAdapter|Binding Liebherr.Lioba.Shell.Views.ShellView and Liebherr.Lioba.Shell.ViewModels.ShellViewModel. 66000|2022-08-15 11:05:02.2377|TRACE||CaliburnLogAdapter|Setting DC of Liebherr.Lioba.Shell.Views.ShellView to Liebherr.Lioba.Shell.ViewModels.ShellViewModel. 66000|2022-08-15 11:05:02.2377|TRACE||CaliburnLogAdapter|Attaching message handler Liebherr.Lioba.Shell.ViewModels.ShellViewModel to Liebherr.Lioba.Shell.Views.ShellView. 66000|2022-08-15 11:05:02.2492|TRACE||CaliburnLogAdapter|Action Convention Not Applied: No actionable element for get_ApplicationBarViewModel. 66000|2022-08-15 11:05:02.2492|TRACE||CaliburnLogAdapter|Action Convention Not Applied: No actionable element for get_BannerRegionViewModels. 66000|2022-08-15 11:05:02.2492|TRACE||CaliburnLogAdapter|Action Convention Not Applied: No actionable element for get_DisplayName. 66000|2022-08-15 11:05:02.2492|TRACE||CaliburnLogAdapter|Action Convention Not Applied: No actionable element for set_DisplayName. 66000|2022-08-15 11:05:02.2492|TRACE||CaliburnLogAdapter|Action Convention Not Applied: No actionable element for get_Icon. 66000|2022-08-15 11:05:02.2492|TRACE||CaliburnLogAdapter|Action Convention Not Applied: No actionable element for get_IsIntegrationMessaging. 66000|2022-08-15 11:05:02.2492|TRACE||CaliburnLogAdapter|Action Convention Not Applied: No actionable element for get_MainRegionViewModel. 66000|2022-08-15 11:05:02.2492|TRACE||CaliburnLogAdapter|Action Convention Not Applied: No actionable element for get_MessageDialogViewModel. 66000|2022-08-15 11:05:02.2492|TRACE||CaliburnLogAdapter|Action Convention Not Applied: No actionable element for get_NavigationViewModel. 66000|2022-08-15 11:05:02.2492|TRACE||CaliburnLogAdapter|Action Convention Not Applied: No actionable element for get_NotificationCenterFlyoutViewModel. 66000|2022-08-15 11:05:02.2492|TRACE||CaliburnLogAdapter|Action Convention Not Applied: No actionable element for get_SettingsFlyoutViewModel. 66000|2022-08-15 11:05:02.2492|TRACE||CaliburnLogAdapter|Action Convention Not Applied: No actionable element for get_ShowNotificationFlyout. 66000|2022-08-15 11:05:02.2492|TRACE||CaliburnLogAdapter|Action Convention Not Applied: No actionable element for get_StatusRegionViewModels. 66000|2022-08-15 11:05:02.2492|TRACE||CaliburnLogAdapter|Action Convention Not Applied: No actionable element for get_ToastNotificationViewModel. 66000|2022-08-15 11:05:02.2492|TRACE||CaliburnLogAdapter|Action Convention Not Applied: No actionable element for DisposeAsync. 66000|2022-08-15 11:05:02.2492|TRACE||CaliburnLogAdapter|Action Convention Not Applied: No actionable element for HandleAsync. 66000|2022-08-15 11:05:02.2492|TRACE||CaliburnLogAdapter|Action Convention Not Applied: No actionable element for HandleAsync. 66000|2022-08-15 11:05:02.2492|TRACE||CaliburnLogAdapter|Action Convention Not Applied: No actionable element for HandleAsync. 66000|2022-08-15 11:05:02.2492|TRACE||CaliburnLogAdapter|Action Convention Not Applied: No actionable element for get_ProgressProvider. 66000|2022-08-15 11:05:02.2492|TRACE||CaliburnLogAdapter|Action Convention Not Applied: No actionable element for get_TaskbarItemProgressState. 66000|2022-08-15 11:05:02.2492|TRACE||CaliburnLogAdapter|Action Convention Not Applied: No actionable element for get_TaskbarItemProgressValue. 66000|2022-08-15 11:05:02.2492|TRACE||CaliburnLogAdapter|Action Convention Not Applied: No actionable element for add_PropertyChanged. 66000|2022-08-15 11:05:02.2492|TRACE||CaliburnLogAdapter|Action Convention Not Applied: No actionable element for remove_PropertyChanged. 66000|2022-08-15 11:05:02.2492|TRACE||CaliburnLogAdapter|Action Convention Not Applied: No actionable element for Equals. 66000|2022-08-15 11:05:02.2492|TRACE||CaliburnLogAdapter|Action Convention Not Applied: No actionable element for GetHashCode. 66000|2022-08-15 11:05:02.2492|TRACE||CaliburnLogAdapter|Action Convention Not Applied: No actionable element for GetType. 66000|2022-08-15 11:05:02.2492|TRACE||CaliburnLogAdapter|Action Convention Not Applied: No actionable element for ToString. 66000|2022-08-15 11:05:02.2989|TRACE||CaliburnLogAdapter|Binding Liebherr.Lioba.Shell.Views.NotificationCenterFlyoutView and Liebherr.Lioba.Shell.ViewModels.NotificationCenterFlyoutViewModel. 66000|2022-08-15 11:05:02.2989|TRACE||CaliburnLogAdapter|Setting DC of Liebherr.Lioba.Shell.Views.NotificationCenterFlyoutView to Liebherr.Lioba.Shell.ViewModels.NotificationCenterFlyoutViewModel. 66000|2022-08-15 11:05:02.2989|TRACE||CaliburnLogAdapter|Attaching message handler Liebherr.Lioba.Shell.ViewModels.NotificationCenterFlyoutViewModel to Liebherr.Lioba.Shell.Views.NotificationCenterFlyoutView. 66000|2022-08-15 11:05:02.2989|TRACE||CaliburnLogAdapter|Action Convention Not Applied: No actionable element for get_ClearNotificationCommand. 66000|2022-08-15 11:05:02.2989|TRACE||CaliburnLogAdapter|Action Convention Not Applied: No actionable element for get_IsOpen. 66000|2022-08-15 11:05:02.2989|TRACE||CaliburnLogAdapter|Action Convention Not Applied: No actionable element for set_IsOpen. 66000|2022-08-15 11:05:02.2989|TRACE||CaliburnLogAdapter|Action Convention Not Applied: No actionable element for get_ViewModels. 66000|2022-08-15 11:05:02.2989|TRACE||CaliburnLogAdapter|Action Convention Not Applied: No actionable element for DisposeAsync. 66000|2022-08-15 11:05:02.2989|TRACE||CaliburnLogAdapter|Action Convention Not Applied: No actionable element for ShowMessageAsync. 66000|2022-08-15 11:05:02.2989|TRACE||CaliburnLogAdapter|Action Convention Not Applied: No actionable element for add_PropertyChanged. 66000|2022-08-15 11:05:02.2989|TRACE||CaliburnLogAdapter|Action Convention Not Applied: No actionable element for remove_PropertyChanged. 66000|2022-08-15 11:05:02.2989|TRACE||CaliburnLogAdapter|Action Convention Not Applied: No actionable element for Equals. 66000|2022-08-15 11:05:02.2989|TRACE||CaliburnLogAdapter|Action Convention Not Applied: No actionable element for GetHashCode. 66000|2022-08-15 11:05:02.2989|TRACE||CaliburnLogAdapter|Action Convention Not Applied: No actionable element for GetType. 66000|2022-08-15 11:05:02.2989|TRACE||CaliburnLogAdapter|Action Convention Not Applied: No actionable element for ToString. 66000|2022-08-15 11:05:02.3735|TRACE||CaliburnLogAdapter|Binding Liebherr.Lioba.Shell.Views.SettingsFlyoutView and Liebherr.Lioba.Shell.ViewModels.SettingsFlyoutViewModel. 66000|2022-08-15 11:05:02.3735|TRACE||CaliburnLogAdapter|Setting DC of Liebherr.Lioba.Shell.Views.SettingsFlyoutView to Liebherr.Lioba.Shell.ViewModels.SettingsFlyoutViewModel. 66000|2022-08-15 11:05:02.3735|TRACE||CaliburnLogAdapter|Attaching message handler Liebherr.Lioba.Shell.ViewModels.SettingsFlyoutViewModel to Liebherr.Lioba.Shell.Views.SettingsFlyoutView. 66000|2022-08-15 11:05:02.3735|TRACE||CaliburnLogAdapter|Action Convention Not Applied: No actionable element for get_BrowseCommunicationLogDirectory. 66000|2022-08-15 11:05:02.3735|TRACE||CaliburnLogAdapter|Action Convention Not Applied: No actionable element for get_CheckCommunicationLogRight. 66000|2022-08-15 11:05:02.3735|TRACE||CaliburnLogAdapter|Action Convention Not Applied: No actionable element for set_CheckCommunicationLogRight. 66000|2022-08-15 11:05:02.3735|TRACE||CaliburnLogAdapter|Action Convention Not Applied: No actionable element for get_CheckForUpdateCommand. 66000|2022-08-15 11:05:02.3735|TRACE||CaliburnLogAdapter|Action Convention Not Applied: No actionable element for get_CommunicationLogDirectory. 66000|2022-08-15 11:05:02.3735|TRACE||CaliburnLogAdapter|Action Convention Not Applied: No actionable element for set_CommunicationLogDirectory. 66000|2022-08-15 11:05:02.3735|TRACE||CaliburnLogAdapter|Action Convention Not Applied: No actionable element for get_CopyToClipboardCommand. 66000|2022-08-15 11:05:02.3735|TRACE||CaliburnLogAdapter|Action Convention Not Applied: No actionable element for get_CurrentLanguage. 66000|2022-08-15 11:05:02.3735|TRACE||CaliburnLogAdapter|Action Convention Not Applied: No actionable element for set_CurrentLanguage. 66000|2022-08-15 11:05:02.3735|TRACE||CaliburnLogAdapter|Action Convention Not Applied: No actionable element for get_CurrentTheme. 66000|2022-08-15 11:05:02.3735|TRACE||CaliburnLogAdapter|Action Convention Not Applied: No actionable element for set_CurrentTheme. 66000|2022-08-15 11:05:02.3735|TRACE||CaliburnLogAdapter|Action Convention Not Applied: No actionable element for get_InstallationId. 66000|2022-08-15 11:05:02.3735|TRACE||CaliburnLogAdapter|Action Convention Not Applied: No actionable element for get_IsApplicationUpdating. 66000|2022-08-15 11:05:02.3735|TRACE||CaliburnLogAdapter|Action Convention Not Applied: No actionable element for get_IsCheckForUpdateAvailable. 66000|2022-08-15 11:05:02.3735|TRACE||CaliburnLogAdapter|Action Convention Not Applied: No actionable element for get_IsCommunicationLogEnabled. 66000|2022-08-15 11:05:02.3735|TRACE||CaliburnLogAdapter|Action Convention Not Applied: No actionable element for set_IsCommunicationLogEnabled. 66000|2022-08-15 11:05:02.3735|TRACE||CaliburnLogAdapter|Action Convention Not Applied: No actionable element for get_IsImportPamsLicenseAvailable. 66000|2022-08-15 11:05:02.3735|TRACE||CaliburnLogAdapter|Action Convention Not Applied: No actionable element for get_IsOpen. 66000|2022-08-15 11:05:02.3735|TRACE||CaliburnLogAdapter|Action Convention Not Applied: No actionable element for set_IsOpen. 66000|2022-08-15 11:05:02.3735|TRACE||CaliburnLogAdapter|Action Convention Not Applied: No actionable element for get_IsPamsLicenseAvailable. 66000|2022-08-15 11:05:02.3735|TRACE||CaliburnLogAdapter|Action Convention Not Applied: No actionable element for get_IsUserInformationOpen. 66000|2022-08-15 11:05:02.3735|TRACE||CaliburnLogAdapter|Action Convention Not Applied: No actionable element for get_Languages. 66000|2022-08-15 11:05:02.3735|TRACE||CaliburnLogAdapter|Action Convention Not Applied: No actionable element for get_ProductName. 66000|2022-08-15 11:05:02.3735|TRACE||CaliburnLogAdapter|Action Convention Not Applied: No actionable element for get_ProductVersion. 66000|2022-08-15 11:05:02.3735|TRACE||CaliburnLogAdapter|Action Convention Not Applied: No actionable element for get_ShowDiaCheckerCommand. 66000|2022-08-15 11:05:02.3735|TRACE||CaliburnLogAdapter|Action Convention Not Applied: No actionable element for get_ShowsIdsInHex. 66000|2022-08-15 11:05:02.3735|TRACE||CaliburnLogAdapter|Action Convention Not Applied: No actionable element for set_ShowsIdsInHex. 66000|2022-08-15 11:05:02.3735|TRACE||CaliburnLogAdapter|Action Convention Not Applied: No actionable element for get_Themes. 66000|2022-08-15 11:05:02.3735|TRACE||CaliburnLogAdapter|Action Convention Not Applied: No actionable element for DisposeAsync. 66000|2022-08-15 11:05:02.3735|TRACE||CaliburnLogAdapter|Action Convention Applied: Action ImportPamsLicense on element ImportPamsLicense. 66000|2022-08-15 11:05:02.4101|FATAL||App|Unexpected exception occurred in LIDIA. System.NullReferenceException: Object reference not set to an instance of an object. at Caliburn.Micro.Parser.<>c.<.cctor>b8_0(DependencyObject target, String triggerText) in D:\a\1\s\src\Caliburn.Micro.Platform\Parser.cs:line 196 at Caliburn.Micro.Parser.Parse(DependencyObject target, String text) in D:\a\1\s\src\Caliburn.Micro.Platform\Parser.cs:line 72 at Caliburn.Micro.Message.OnAttachChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) in D:\a\1\s\src\Caliburn.Micro.Platform\Message.cs:line 131 at System.Windows.DependencyObject.OnPropertyChanged(DependencyPropertyChangedEventArgs e) at System.Windows.FrameworkElement.OnPropertyChanged(DependencyPropertyChangedEventArgs e) at System.Windows.DependencyObject.NotifyPropertyChange(DependencyPropertyChangedEventArgs args) at System.Windows.DependencyObject.UpdateEffectiveValue(EntryIndex entryIndex, DependencyProperty dp, PropertyMetadata metadata, EffectiveValueEntry oldEntry, EffectiveValueEntry& newEntry, Boolean coerceWithDeferredReference, Boolean coerceWithCurrentValue, OperationType operationType) at System.Windows.DependencyObject.SetValueCommon(DependencyProperty dp, Object value, PropertyMetadata metadata, Boolean coerceWithDeferredReference, Boolean coerceWithCurrentValue, OperationType operationType, Boolean isInternal) at Caliburn.Micro.ViewModelBinder.<>c.<.cctor>b__10_1(IEnumerable`1 namedElements, Type viewModelType) in D:\a\1\s\src\Caliburn.Micro.Platform\ViewModelBinder.cs:line 175 at Caliburn.Micro.ViewModelBinder.<>c.<.cctor>b10_3(Object viewModel, DependencyObject view, Object context) in D:\a\1\s\src\Caliburn.Micro.Platform\ViewModelBinder.cs:line 255 at Caliburn.Micro.View.OnModelChanged(DependencyObject targetLocation, DependencyPropertyChangedEventArgs args) in D:\a\1\s\src\Caliburn.Micro.Platform\View.cs:line 310 at System.Windows.DependencyObject.OnPropertyChanged(DependencyPropertyChangedEventArgs e) at System.Windows.FrameworkElement.OnPropertyChanged(DependencyPropertyChangedEventArgs e) at System.Windows.DependencyObject.NotifyPropertyChange(DependencyPropertyChangedEventArgs args) at System.Windows.DependencyObject.UpdateEffectiveValue(EntryIndex entryIndex, DependencyProperty dp, PropertyMetadata metadata, EffectiveValueEntry oldEntry, EffectiveValueEntry& newEntry, Boolean coerceWithDeferredReference, Boolean coerceWithCurrentValue, OperationType operationType) at System.Windows.DependencyObject.InvalidateProperty(DependencyProperty dp, Boolean preserveCurrentValue) at System.Windows.Data.BindingExpressionBase.Invalidate(Boolean isASubPropertyChange) at System.Windows.Data.BindingExpression.TransferValue(Object newValue, Boolean isASubPropertyChange) at System.Windows.Data.BindingExpression.Activate(Object item) at System.Windows.Data.BindingExpression.AttachToContext(AttachAttempt attempt) at System.Windows.Data.BindingExpression.MS.Internal.Data.IDataBindEngineClient.AttachToContext(Boolean lastChance) at MS.Internal.Data.DataBindEngine.Task.Run(Boolean lastChance) at MS.Internal.Data.DataBindEngine.Run(Object arg) at MS.Internal.Data.DataBindEngine.OnLayoutUpdated(Object sender, EventArgs e) at System.Windows.ContextLayoutManager.fireLayoutUpdateEvent() at System.Windows.ContextLayoutManager.UpdateLayout() at System.Windows.UIElement.UpdateLayout() at System.Windows.Interop.HwndSource.Process_WM_SIZE(UIElement rootUIElement, IntPtr hwnd, WindowMessage msg, IntPtr wParam, IntPtr lParam) at System.Windows.Interop.HwndSource.LayoutFilterMessage(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled) at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled) at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o) at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs) at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler) at Caliburn.Micro.Parser.<>c.<.cctor>b8_0(DependencyObject target, String triggerText) in D:\a\1\s\src\Caliburn.Micro.Platform\Parser.cs:line 196 at Caliburn.Micro.Parser.Parse(DependencyObject target, String text) in D:\a\1\s\src\Caliburn.Micro.Platform\Parser.cs:line 72 at Caliburn.Micro.Message.OnAttachChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) in D:\a\1\s\src\Caliburn.Micro.Platform\Message.cs:line 131 at System.Windows.DependencyObject.OnPropertyChanged(DependencyPropertyChangedEventArgs e) at System.Windows.FrameworkElement.OnPropertyChanged(DependencyPropertyChangedEventArgs e) at System.Windows.DependencyObject.NotifyPropertyChange(DependencyPropertyChangedEventArgs args) at System.Windows.DependencyObject.UpdateEffectiveValue(EntryIndex entryIndex, DependencyProperty dp, PropertyMetadata metadata, EffectiveValueEntry oldEntry, EffectiveValueEntry& newEntry, Boolean coerceWithDeferredReference, Boolean coerceWithCurrentValue, OperationType operationType) at System.Windows.DependencyObject.SetValueCommon(DependencyProperty dp, Object value, PropertyMetadata metadata, Boolean coerceWithDeferredReference, Boolean coerceWithCurrentValue, OperationType operationType, Boolean isInternal) at Caliburn.Micro.ViewModelBinder.<>c.<.cctor>b__10_1(IEnumerable`1 namedElements, Type viewModelType) in D:\a\1\s\src\Caliburn.Micro.Platform\ViewModelBinder.cs:line 175 at Caliburn.Micro.ViewModelBinder.<>c.<.cctor>b10_3(Object viewModel, DependencyObject view, Object context) in D:\a\1\s\src\Caliburn.Micro.Platform\ViewModelBinder.cs:line 255 at Caliburn.Micro.View.OnModelChanged(DependencyObject targetLocation, DependencyPropertyChangedEventArgs args) in D:\a\1\s\src\Caliburn.Micro.Platform\View.cs:line 310 at System.Windows.DependencyObject.OnPropertyChanged(DependencyPropertyChangedEventArgs e) at System.Windows.FrameworkElement.OnPropertyChanged(DependencyPropertyChangedEventArgs e) at System.Windows.DependencyObject.NotifyPropertyChange(DependencyPropertyChangedEventArgs args) at System.Windows.DependencyObject.UpdateEffectiveValue(EntryIndex entryIndex, DependencyProperty dp, PropertyMetadata metadata, EffectiveValueEntry oldEntry, EffectiveValueEntry& newEntry, Boolean coerceWithDeferredReference, Boolean coerceWithCurrentValue, OperationType operationType) at System.Windows.DependencyObject.InvalidateProperty(DependencyProperty dp, Boolean preserveCurrentValue) at System.Windows.Data.BindingExpressionBase.Invalidate(Boolean isASubPropertyChange) at System.Windows.Data.BindingExpression.TransferValue(Object newValue, Boolean isASubPropertyChange) at System.Windows.Data.BindingExpression.Activate(Object item) at System.Windows.Data.BindingExpression.AttachToContext(AttachAttempt attempt) at System.Windows.Data.BindingExpression.MS.Internal.Data.IDataBindEngineClient.AttachToContext(Boolean lastChance) at MS.Internal.Data.DataBindEngine.Task.Run(Boolean lastChance) at MS.Internal.Data.DataBindEngine.Run(Object arg) at MS.Internal.Data.DataBindEngine.OnLayoutUpdated(Object sender, EventArgs e) at System.Windows.ContextLayoutManager.fireLayoutUpdateEvent() at System.Windows.ContextLayoutManager.UpdateLayout() at System.Windows.UIElement.UpdateLayout() at System.Windows.Interop.HwndSource.Process_WM_SIZE(UIElement rootUIElement, IntPtr hwnd, WindowMessage msg, IntPtr wParam, IntPtr lParam) at System.Windows.Interop.HwndSource.LayoutFilterMessage(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled) at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled) at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o) at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs) at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)

66000|2022-08-15 11:05:03.8085|TRACE||IdentificationService|CurrentIdentity = Radosavljevic Nikola ExternalConsultant 66000|2022-08-15 11:05:03.8261|TRACE||RightsLoader|Loading rights for Radosavljevic Nikola ExternalConsultant 66000|2022-08-15 11:05:04.2453|INFO||RightsLoader|Rights loaded for Radosavljevic Nikola ExternalConsultant 66000|2022-08-15 11:05:04.7469|TRACE||AuthenticationService|Status = Radosavljevic Nikola ExternalConsultant, Authenticated = True 66000|2022-08-15 11:05:04.7469|TRACE||AuthenticationService|Status = Radosavljevic Nikola ExternalConsultant, Authenticated = True 66000|2022-08-15 11:05:07.3306|FATAL||LiobaWpfBootstrapper|Unhandled exception from System.Windows.Threading.Dispatcher! 66000|2022-08-15 11:05:07.3357|TRACE||CaliburnLogAdapter|ViewModel bound on MessageDialogViewModel. 66000|2022-08-15 11:05:07.3576|TRACE||CaliburnLogAdapter|Binding Liebherr.Lioba.Client.Wpf.Views.MessageDialogView and Liebherr.Lioba.Client.Wpf.ViewModels.MessageDialogViewModel. 66000|2022-08-15 11:05:07.3576|TRACE||CaliburnLogAdapter|Setting DC of Liebherr.Lioba.Client.Wpf.Views.MessageDialogView to Liebherr.Lioba.Client.Wpf.ViewModels.MessageDialogViewModel. 66000|2022-08-15 11:05:07.3576|TRACE||CaliburnLogAdapter|Attaching message handler Liebherr.Lioba.Client.Wpf.ViewModels.MessageDialogViewModel to Liebherr.Lioba.Client.Wpf.Views.MessageDialogView. 66000|2022-08-15 11:05:07.3576|TRACE||CaliburnLogAdapter|Action Convention Not Applied: No actionable element for get_ActiveMessage. 66000|2022-08-15 11:05:07.3576|TRACE||CaliburnLogAdapter|Action Convention Not Applied: No actionable element for get_CloseActiveMessageCommand. 66000|2022-08-15 11:05:07.3576|TRACE||CaliburnLogAdapter|Action Convention Not Applied: No actionable element for get_IsVisible. 66000|2022-08-15 11:05:07.3576|TRACE||CaliburnLogAdapter|Action Convention Not Applied: No actionable element for DisposeAsync. 66000|2022-08-15 11:05:07.3576|TRACE||CaliburnLogAdapter|Action Convention Not Applied: No actionable element for HandleAsync. 66000|2022-08-15 11:05:07.3576|TRACE||CaliburnLogAdapter|Action Convention Not Applied: No actionable element for ShowAsync. 66000|2022-08-15 11:05:07.3576|TRACE||CaliburnLogAdapter|Action Convention Not Applied: No actionable element for add_PropertyChanged. 66000|2022-08-15 11:05:07.3576|TRACE||CaliburnLogAdapter|Action Convention Not Applied: No actionable element for remove_PropertyChanged. 66000|2022-08-15 11:05:07.3576|TRACE||CaliburnLogAdapter|Action Convention Not Applied: No actionable element for Equals. 66000|2022-08-15 11:05:07.3576|TRACE||CaliburnLogAdapter|Action Convention Not Applied: No actionable element for GetHashCode. 66000|2022-08-15 11:05:07.3576|TRACE||CaliburnLogAdapter|Action Convention Not Applied: No actionable element for GetType. 66000|2022-08-15 11:05:07.3576|TRACE||CaliburnLogAdapter|Action Convention Not Applied: No actionable element for ToString. 66000|2022-08-15 11:05:07.3576|TRACE||CaliburnLogAdapter|Binding Convention Not Applied: Element MessageDialogControl did not match a property. 66000|2022-08-15 11:05:07.3576|TRACE||CaliburnLogAdapter|Binding Convention Not Applied: Element ContentBox did not match a property. 66000|2022-08-15 11:05:07.3576|TRACE||CaliburnLogAdapter|Binding Convention Not Applied: Element CustomContentBox did not match a property. 66000|2022-08-15 11:05:07.3576|TRACE||CaliburnLogAdapter|Binding Convention Applied: Element MessageDialogViewModel. 66000|2022-08-15 11:05:07.3576|TRACE||CaliburnLogAdapter|ViewModel bound on ApplicationBarViewModel. 66000|2022-08-15 11:05:07.3576|TRACE||CaliburnLogAdapter|Binding Convention Not Applied: Element ApplicationBarViewModel has existing binding. 66000|2022-08-15 11:05:08.3163|INFO||NavigationService|Navigating to HomeScreenViewModel. 66000|2022-08-15 11:05:08.3242|TRACE||HelpUICommandViewModel|Looking for help files in Shell.Home 66000|2022-08-15 11:05:08.3242|DEBUG||App|NBug settings UIMode set to None. 66000|2022-08-15 11:05:08.3654|TRACE||AuthenticationService|Status = Radosavljevic Nikola ExternalConsultant, Authenticated = True 66000|2022-08-15 11:05:08.3790|INFO||NavigationService|Navigation to HomeScreenViewModel complete. 66000|2022-08-15 11:05:08.3933|TRACE||AuthenticationService|Status = Radosavljevic Nikola ExternalConsultant, Authenticated = True 66000|2022-08-15 11:05:08.3990|TRACE||AuthenticationService|Status = Radosavljevic Nikola ExternalConsultant, Authenticated = True

I have attempted to figure out why the exception occurs, but it's a bit convoluted for me.

According to the log file, exception occurs on hightlighted line of Caliburn Parser.cs file image

This implies to me that target is null on the hightlighted line. Looking down the call stack, this should not be possible unless .NET Framework passes null.

Looking further at .NET Framework with ILSpy, it shouldn't be possible that null is passed. image As visible, this is passed for the target argument, and here my brain freezes.

Second approach

Now, investigating in reverse, starting not from exception but previous line in the log.

66000|2022-08-15 11:05:02.3735|TRACE||CaliburnLogAdapter|Action Convention Applied: Action ImportPamsLicense on element ImportPamsLicense.

Caliburn logs this line in ViewModelBinder.cs. image

Right after this is logged, a call to Message.SetAttach(foundControl, message);. Interestingly, this call doesn't appear in call stack. Lack of the method in call stack leads me to believe that failure happens inside static initializer of AttachProperty DependencyProperty. Unfortunately, looking into initializers did not help me find out how a call to OnPropertyChanged could be made with null for target.

Third approach

Now assuming that there is some magic that makes call stack inconsistent, I just want to find out whether Caliburn can make a call below with foundControl being null.

Message.SetAttach(foundControl, message); Here I'm already making a big guess that this null would somehow propagate down to OnPropertyChanged. This does not look possible either. I'm now completely lost.

Thanks for any hints!

KasperSK commented 2 years ago

Does it work if you remove the button?

Could you upload a repro of this issue? I think a debugger would be very helpful here.