Why getting error exception Managed Debugging Assistant 'FatalExecutionEngineError' : 'The runtime has encountered a fatal error and how to fix it ?

Sani Berko 41 Reputation points
2022-08-13T19:37:34.707+00:00

Tried to google for answer but didn't find something that work or a clean solution.

I'm using visual studio 2022 community. Windows 10 pro.

The project is wpf type.

i1zLK.jpg

Sometimes it happens in the code on this line :

string StringFromRichTextBox(System.Windows.Controls.RichTextBox rtb)  
        {  
            TextRange textRange = new TextRange(  
                rtb.Document.ContentStart,  
                rtb.Document.ContentEnd  
            );  
  
            return textRange.Text;  
        }  

On the line :

return textRange.Text;  
Windows Presentation Foundation
Windows Presentation Foundation
A part of the .NET Framework that provides a unified programming model for building line-of-business desktop applications on Windows.
2,676 questions
C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,275 questions
XAML
XAML
A language based on Extensible Markup Language (XML) that enables developers to specify a hierarchy of objects with a set of properties and logic.
766 questions
0 comments No comments
{count} votes

Accepted answer
  1. Viorel 112.5K Reputation points
    2022-08-13T20:16:22.297+00:00

    I think that there are certain reasons to try this fix of '+=' operations:

    fsw.Changed += ( s, a ) => Dispatcher.Invoke( ( ) => Fsw_Changed( s, a ) );  
    fsw.Created += ( s, a ) => Dispatcher.Invoke( ( ) => Fsw_Created( s, a ) );  
    fsw.Deleted += ( s, a ) => Dispatcher.Invoke( ( ) => Fsw_Deleted( s, a ) );  
    fsw.Renamed += ( s, a ) => Dispatcher.Invoke( ( ) => Fsw_Renamed( s, a ) );  
    

    Or, instead of these changes, try a shorter fix:

    fsw.SynchronizingObject = this;  
    
    0 comments No comments

0 additional answers

Sort by: Most helpful