Note that there are some explanatory texts on larger screens.

plurals
  1. POStack overflow when opening menu with ApplicationCommands in C#
    primarykey
    data
    text
    <p>When I add an ApplicationCommands command to a MenuItem in my file menu, no matter via XAML or via code, when I open the menu the application crashes in a stack overflow, with absolutely no details about the problem. When I remove the Command, the problem also disappears. It doesn't matter which ApplicationCommand I use.</p> <p>Part of the call stack:</p> <ul> <li>WindowsBase.dll!MS.Utility.ArrayItemList.ArrayItemList(int size) + 0x20 bytes </li> <li>WindowsBase.dll!MS.Utility.FrugalStructList.Capacity.set(int value) + 0x6a bytes </li> <li>WindowsBase.dll!MS.Utility.FrugalStructList.FrugalStructList(int size) + 0x9 bytes </li> <li>PresentationCore.dll!System.Windows.EventRoute.EventRoute(System.Windows.RoutedEvent routedEvent) + 0x35 bytes </li> <li>PresentationCore.dll!System.Windows.EventRouteFactory.FetchObject(System.Windows.RoutedEvent routedEvent) + 0x31 bytes </li> <li>PresentationCore.dll!System.Windows.UIElement.RaiseEventImpl(System.Windows.DependencyObject sender = {System.Windows.Controls.RichTextBox}, System.Windows.RoutedEventArgs args = {System.Windows.Input.CanExecuteRoutedEventArgs}) + 0x3f bytes</li> <li>PresentationCore.dll!System.Windows.UIElement.RaiseEvent(System.Windows.RoutedEventArgs args = {System.Windows.Input.CanExecuteRoutedEventArgs}, bool trusted) + 0x35 bytes </li> <li>PresentationCore.dll!System.Windows.Input.RoutedCommand.CriticalCanExecuteWrapper(object parameter, System.Windows.IInputElement target, bool trusted, System.Windows.Input.CanExecuteRoutedEventArgs args) + 0x80 bytes<br> PresentationCore.dll!System.Windows.Input.RoutedCommand.CanExecuteImpl(object parameter = null, System.Windows.IInputElement target = {System.Windows.Controls.RichTextBox}, bool trusted = false, out bool continueRouting = false) + 0x70 bytes </li> <li>PresentationCore.dll!System.Windows.Input.RoutedCommand.CriticalCanExecute(object parameter, System.Windows.IInputElement target, bool trusted, out bool continueRouting) + 0x3a bytes</li> <li>PresentationCore.dll!System.Windows.Input.CommandManager.TransferEvent(System.Windows.IInputElement newSource, System.Windows.Input.CanExecuteRoutedEventArgs e = {System.Windows.Input.CanExecuteRoutedEventArgs}) + 0x52 bytes</li> <li>PresentationCore.dll!System.Windows.Input.CommandManager.OnCanExecute(object sender, System.Windows.Input.CanExecuteRoutedEventArgs e) + 0x8c bytes<br> PresentationCore.dll!System.Windows.UIElement.OnCanExecuteThunk(object sender, System.Windows.Input.CanExecuteRoutedEventArgs e) + 0x44 bytes</li> <li>PresentationCore.dll!System.Windows.Input.CanExecuteRoutedEventArgs.InvokeEventHandler(System.Delegate genericHandler, object target) + 0x41 bytes<br> PresentationCore.dll!System.Windows.RoutedEventArgs.InvokeHandler(System.Delegate handler, object target) + 0x27 bytes PresentationCore.dll!System.Windows.RoutedEventHandlerInfo.InvokeHandler(object target, System.Windows.RoutedEventArgs routedEventArgs) + 0x3e bytes<br> PresentationCore.dll!System.Windows.EventRoute.InvokeHandlersImpl(object source = {System.Windows.Controls.RichTextBox}, System.Windows.RoutedEventArgs args = {System.Windows.Input.CanExecuteRoutedEventArgs}, bool reRaised = false) + 0x1bf bytes</li> <li>PresentationCore.dll!System.Windows.UIElement.RaiseEventImpl(System.Windows.DependencyObject sender = {System.Windows.Controls.RichTextBox}, System.Windows.RoutedEventArgs args = + 0x79 bytes</li> <li>PresentationCore.dll!System.Windows.UIElement.RaiseEvent(System.Windows.RoutedEventArgs args = {System.Windows.Input.CanExecuteRoutedEventArgs}, bool trusted) + 0x35 bytes</li> <li>PresentationCore.dll!System.Windows.Input.RoutedCommand.CriticalCanExecuteWrapper(object parameter, System.Windows.IInputElement target, bool trusted, System.Windows.Input.CanExecuteRoutedEventArgs args) + 0x80 bytes</li> </ul> <p>It looks like the application is stuck in an endless loop. Is this my fault (and what am I doing wrong) or a bug in .NET 3.5?</p> <p>I use this code:</p> <pre><code>MenuItem mi = new MenuItem(); mi.Command = ApplicationCommands.Open; FileMenu.Items.Add(mi); </code></pre> <p>It doesn't matter wheter I create the menuItem via code or in XAML, and like I said setting the Command also doesn't matter where. The problem also occurs when using MediaCommands, so I guess for all Commands in general.</p> <p>The RichTextBox code:</p> <pre><code>//configure richtextbox sb = new RichTextBox(); sb.Margin = new Thickness(-3); sb.BorderThickness = new Thickness(0); sb.HorizontalScrollBarVisibility = ScrollBarVisibility.Auto; sb.VerticalScrollBarVisibility = ScrollBarVisibility.Auto; ///TODO: get font from preferences. FontFamilyConverter ffc = new FontFamilyConverter(); sb.FontFamily = (FontFamily)ffc.ConvertFromString("Lucida Sans Unicode"); sb.FontSize = 13; sb.AcceptsReturn = true; sb.AcceptsTab = true; sb.AllowDrop = true; sb.IsDocumentEnabled = false; sb.Padding = new Thickness(5); //markup styles Style s = new Style(typeof(Paragraph)); s.Setters.Add(new Setter(Paragraph.MarginProperty, new Thickness(0))); sb.Resources.Add(typeof(Paragraph), s); this.AddChild(sb); </code></pre> <p>The RichTextBox is added in the constructor of a control that is derived from TabItem.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload