Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 267663
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T23:35:16+00:00 2026-05-11T23:35:16+00:00

When I add an ApplicationCommands command to a MenuItem in my file menu, no

  • 0

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.

Part of the call stack:

  • WindowsBase.dll!MS.Utility.ArrayItemList.ArrayItemList(int
    size) + 0x20 bytes
  • WindowsBase.dll!MS.Utility.FrugalStructList.Capacity.set(int
    value) + 0x6a bytes
  • WindowsBase.dll!MS.Utility.FrugalStructList.FrugalStructList(int
    size) + 0x9 bytes
  • PresentationCore.dll!System.Windows.EventRoute.EventRoute(System.Windows.RoutedEvent
    routedEvent) + 0x35 bytes
  • PresentationCore.dll!System.Windows.EventRouteFactory.FetchObject(System.Windows.RoutedEvent
    routedEvent) + 0x31 bytes
  • PresentationCore.dll!System.Windows.UIElement.RaiseEventImpl(System.Windows.DependencyObject
    sender =
    {System.Windows.Controls.RichTextBox},
    System.Windows.RoutedEventArgs args =
    {System.Windows.Input.CanExecuteRoutedEventArgs}) + 0x3f bytes
  • PresentationCore.dll!System.Windows.UIElement.RaiseEvent(System.Windows.RoutedEventArgs
    args =
    {System.Windows.Input.CanExecuteRoutedEventArgs},
    bool trusted) + 0x35 bytes
  • PresentationCore.dll!System.Windows.Input.RoutedCommand.CriticalCanExecuteWrapper(object
    parameter,
    System.Windows.IInputElement target,
    bool trusted,
    System.Windows.Input.CanExecuteRoutedEventArgs
    args) + 0x80 bytes
    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
  • PresentationCore.dll!System.Windows.Input.RoutedCommand.CriticalCanExecute(object
    parameter,
    System.Windows.IInputElement target,
    bool trusted, out bool
    continueRouting) + 0x3a bytes
  • PresentationCore.dll!System.Windows.Input.CommandManager.TransferEvent(System.Windows.IInputElement
    newSource,
    System.Windows.Input.CanExecuteRoutedEventArgs
    e =
    {System.Windows.Input.CanExecuteRoutedEventArgs}) + 0x52 bytes
  • PresentationCore.dll!System.Windows.Input.CommandManager.OnCanExecute(object
    sender,
    System.Windows.Input.CanExecuteRoutedEventArgs
    e) + 0x8c bytes
    PresentationCore.dll!System.Windows.UIElement.OnCanExecuteThunk(object
    sender,
    System.Windows.Input.CanExecuteRoutedEventArgs
    e) + 0x44 bytes
  • PresentationCore.dll!System.Windows.Input.CanExecuteRoutedEventArgs.InvokeEventHandler(System.Delegate
    genericHandler, object target) + 0x41
    bytes
    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
    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
  • PresentationCore.dll!System.Windows.UIElement.RaiseEventImpl(System.Windows.DependencyObject
    sender =
    {System.Windows.Controls.RichTextBox},
    System.Windows.RoutedEventArgs args = + 0x79 bytes
  • PresentationCore.dll!System.Windows.UIElement.RaiseEvent(System.Windows.RoutedEventArgs
    args =
    {System.Windows.Input.CanExecuteRoutedEventArgs},
    bool trusted) + 0x35 bytes
  • PresentationCore.dll!System.Windows.Input.RoutedCommand.CriticalCanExecuteWrapper(object
    parameter,
    System.Windows.IInputElement target,
    bool trusted,
    System.Windows.Input.CanExecuteRoutedEventArgs
    args) + 0x80 bytes

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?

I use this code:

MenuItem mi = new MenuItem();
mi.Command = ApplicationCommands.Open;
FileMenu.Items.Add(mi);

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.

The RichTextBox 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);

The RichTextBox is added in the constructor of a control that is derived from TabItem.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-11T23:35:17+00:00Added an answer on May 11, 2026 at 11:35 pm

    I found the problem. I was adding my RichTextBox to a focus group. I removed that and now it works. Altough I still can’t get the keyboard focus in the RichTextBox at startup. (Tried Keyboard.Focus(sb), sb.Focus(), sb.Document.Focus(), Keyboard.Focus(sb.Document), FocusManager.SetFocusedElement(this, sb), ect…

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 143k
  • Answers 143k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer I noticed you're missing [ComVisible(true)]. Interface header should look like:… May 12, 2026 at 8:28 am
  • Editorial Team
    Editorial Team added an answer "text/javascript" is the only type that is supported by all… May 12, 2026 at 8:28 am
  • Editorial Team
    Editorial Team added an answer Yup, Console.WriteLine etc will work just fine in a class… May 12, 2026 at 8:28 am

Related Questions

When I add an assembly reference to a project in Visual Studio 8 the
When I add an HTTP handler: <add verb=* path=*test.aspx type=Handler/> With the class: using
When I add an element in the controls node, the .aspx doesn't reflect it
I am trying to add an info button to my app to provide custom

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.