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
I have a contextmenu with one option "Move To" with some dynamically added sub-menuitems "destinations", which are create by binding the itemsource of the top menu item to an observableCollection of strings. All of these sub-menuitems share the same Command, and pass their header as the command parameter.
The first time I open the context menu and chose a destination, everything works fine. The second time you open the context menu however, the application crashes with the following error.
{"Parameter \"parameter\" (object) cannot be of type MS.Internal.NamedObject, as the command type requires an argument of type System.String. (Parameter 'parameter')"}
By putting a value converter on the command parameter binding and putting a breakpoint inside, I could inspect the problematic parameter and it is a MS.Internal.NamedObject, with name DisconnectedItem.
Simply click the button and chose a destination option, you will see a messagebox showing that it works. Click the btn again, you will see another messagebox showing the exception because it crashed.
The repo consists of these 3 simple files:
MainWindow.xaml
publicpartialclassMainViewModel{publicObservableCollection<string> Destinations {get;}=["loc1","loc2","loc3"];[RelayCommand]publicvoidMove(string?destination){if(string.IsNullOrEmpty(destination)){thrownew ArgumentNullException(nameof(destination));}//do something here
MessageBox.Show($"Moved something to {destination}");}}
Expected behavior
Definitely not crash, when CanExcecute is called with DisconnectedItem as parameter, it should probably just return false.
Screenshots
No response
IDE and version
VS 2022
IDE version
Version 17.9.1
Nuget packages
CommunityToolkit.Common
CommunityToolkit.Diagnostics
CommunityToolkit.HighPerformance
CommunityToolkit.Mvvm (aka MVVM Toolkit)
Nuget package version(s)
8.2.2
Additional context
No response
Help us help you
No, just wanted to report this
The text was updated successfully, but these errors were encountered:
Describe the bug
I have a contextmenu with one option "Move To" with some dynamically added sub-menuitems "destinations", which are create by binding the itemsource of the top menu item to an observableCollection of strings. All of these sub-menuitems share the same Command, and pass their header as the command parameter.
The first time I open the context menu and chose a destination, everything works fine. The second time you open the context menu however, the application crashes with the following error.
By putting a value converter on the command parameter binding and putting a breakpoint inside, I could inspect the problematic parameter and it is a
MS.Internal.NamedObject
, with nameDisconnectedItem
.The only info I could find is this https://learn.microsoft.com/en-us/archive/msdn-technet-forums/36aec363-9e33-45bd-81f0-1325a735cc45 and this https://stackoverflow.com/questions/3868786/wpf-sentinel-objects-and-how-to-check-for-an-internal-type.
Stacktrace:
Regression
No response
Steps to reproduce
I made a minimal repo to reproduce the crash https://github.com/DSPaul/CrashOnDisconnectedItem.
Simply click the button and chose a destination option, you will see a messagebox showing that it works. Click the btn again, you will see another messagebox showing the exception because it crashed.
The repo consists of these 3 simple files:
MainWindow.xaml
MainWindow.xaml.cs
MainViewModel
Expected behavior
Definitely not crash, when CanExcecute is called with DisconnectedItem as parameter, it should probably just return false.
Screenshots
No response
IDE and version
VS 2022
IDE version
Version 17.9.1
Nuget packages
Nuget package version(s)
8.2.2
Additional context
No response
Help us help you
No, just wanted to report this
The text was updated successfully, but these errors were encountered: