locked
An unhandled exception of type 'System.ExecutionEngineException' occurred in WindowsBase.dll RRS feed

  • Question

  • Hello MSDN

    I am getting this exception in my .Net 4.5 WPF application (also in .Net 4.0) running on a Windows 7 Ultimate SP1 64-bit machine:

    "An unhandled exception of type 'System.ExecutionEngineException' occurred in WindowsBase.dll"

    And I can't find out what is causing this problem.

    I need to be able to update the property bound to the text box both from code (the prototype is simulating an update from a data storage using a timer) and from the GUI (simulation a user change). When a data update is received (generated on timer elapsed) the user/GUI needs to be notified. So I need the INotifyPropertyChanged implementation.

    I have made a small application to demonstrate the problem. In a new WPF project add the following to the MainWindow.xaml file:

    <Window x:Class="WpfApplication10.MainWindow"
            xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
            xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
            Title="MainWindow" Height="350" Width="525">
        <StackPanel HorizontalAlignment="Center" VerticalAlignment="Center">
            <TextBox Text="{Binding MyText}" Width="100" />
        </StackPanel>
    </Window>
    

    And in the MainWindow.xaml.cs file add the following:

    using System;
    using System.ComponentModel;
    using System.Timers;
    using System.Windows;
     
    namespace WpfApplication10
    {
       /// <summary>
       /// Interaction logic for MainWindow.xaml
       /// </summary>
       public partial class MainWindow : WindowINotifyPropertyChanged
       {
          private string m_MyText;
          public string MyText
          {
             get
             {
                return m_MyText;
             }
             set
             {
                if ( m_MyText == value )
                {
                   return;
                }
     
                m_MyText = value;
                NotifyPropertyChanged( "MyText" );
             }
          }
     
          public MainWindow()
          {
             InitializeComponent();
     
             DataContext = this;
     
             Timer t = new Timer();
             t.Interval = 10000;
             t.Elapsed += t_Elapsed;
             t.Start();
          }
     
          void t_Elapsed( object sender, ElapsedEventArgs e )
          {
             MyText = DateTime.Now.ToLongTimeString();
          }
     
          #region INotifyPropertyChanged Members
     
          public event PropertyChangedEventHandler PropertyChanged;
     
          private void NotifyPropertyChanged( string propertyName = "" )
          {
             if ( PropertyChanged != null )
             {
                PropertyChanged( thisnew PropertyChangedEventArgs( propertyName ) );
             }
          }
     
          #endregion
       }
    }
    

    To reproduce the exception follow the following steps:

    1. Press the windows start button.

    2. Enter "tabtip.exe" and press the enter key to start the Tablet PC Input Panel.

    3. Run the demo application.

    4. Click the text box in the middle of the demo application to focus the text box .

    5. In the Tablet PC Input Panel go to hand writing recognition by clicking the "Writing Pad" icon in the top left corner. (if hand writing recognition is not available try changing the language by the drop down inside Tablet PC Input Panel).

    6. Enter some text for example the letters "Car".

    7. Without clicking anywhere wait for the text in the text box to AUTOMATICALLY update its text to a new time stamp (updated by the timer elapsed event).

    8. Click the text box.

    This is all it needs to crash. 

    Can anybody tell me what I am doing wrong here?

    In advance,

    Thank you

    Best regards,

    Casper Korshøj


    Thursday, September 19, 2013 11:24 AM

Answers

  • Hi Casper Korshøj,

    The problem lies with the following code snippet..

    private void NotifyPropertyChanged( string propertyName = "" )
          {
             if ( PropertyChanged != null )
             {
                PropertyChanged( this, new PropertyChangedEventArgs( propertyName ) );  //comment this line to prevent hanging
             }
          }

    the method call through event handler "PropertyChanged( this, new PropertyChangedEventArgs( propertyName ) )" is interfering with the application "tabtip.exe" and that's why your application is getting hanged.

    if you comment  PropertyChanged( this, new PropertyChangedEventArgs( propertyName ) ); line or if you do in other way to reflect the changed time displayed in the text box, your application will not hang.

    • Proposed as answer by MalleswaraRaoMareedu Friday, September 20, 2013 3:55 AM
    • Marked as answer by Eason_H Thursday, September 26, 2013 1:17 AM
    Thursday, September 19, 2013 12:57 PM

All replies

  • Hi Casper Korshøj,

    The problem lies with the following code snippet..

    private void NotifyPropertyChanged( string propertyName = "" )
          {
             if ( PropertyChanged != null )
             {
                PropertyChanged( this, new PropertyChangedEventArgs( propertyName ) );  //comment this line to prevent hanging
             }
          }

    the method call through event handler "PropertyChanged( this, new PropertyChangedEventArgs( propertyName ) )" is interfering with the application "tabtip.exe" and that's why your application is getting hanged.

    if you comment  PropertyChanged( this, new PropertyChangedEventArgs( propertyName ) ); line or if you do in other way to reflect the changed time displayed in the text box, your application will not hang.

    • Proposed as answer by MalleswaraRaoMareedu Friday, September 20, 2013 3:55 AM
    • Marked as answer by Eason_H Thursday, September 26, 2013 1:17 AM
    Thursday, September 19, 2013 12:57 PM
  • Thank you for the response Ravi kumar Kantipudi.

    I need to be able to update the GUI when the property is changed from code. So I can't remove the INotifyPropertyChanged implementation. (?) Is it not possible to avoid the crash without commenting the line?

    I have updated the question to make this clear.

    Thursday, September 19, 2013 1:20 PM
  • Hi Casper Korshøj,

    Your code in the application is fine and the reason for crash of your application is, that "tabtip.exe" is acquiring access to textbox and locking the text box forever and your application is waiting indefinetely and finally getting crashed. I have tried to prevent this deadlock through code but could not succeed.(none of classes/methods/properties in System.Threading namespace is allowing to find out locked objects/raceconditions/deadlocks).

    but one possible workaround for your case is, you can disable the text box in following way..

    <TextBoxText="{BindingMyText}"Width="100"IsEnabled="False" />

    so that "tabtip.exe" can't access your textbox.

    Tuesday, September 24, 2013 12:02 PM
  • I think you are right about that it has something to do with "tabtip.exe" is acquiring access to the text box and locking. But if "tabtip.exe" has got the lock for the text box, how can I update the text box from code behind during the timer elapsed event?

    Disabling the text box would not solve my problem, because I need to be able to edit the property from GUI. But maybe I need to find an alternative approach to manipulate it.

    Again, thank you for your response, Ravi kumar Kantipudi, and effort.

    I am wondering if the problem could reside in "tabtip.exe"?

    Tuesday, September 24, 2013 12:40 PM