FailFast exception when reflecting over wpf properties
See original GitHub issue- .NET Core Version: 5.0+
- Windows version: Windows 11
- Does the bug reproduce also in WPF for .NET Framework 4.8?: Yes
- Is this bug related specifically to tooling in Visual Studio (e.g. XAML Designer, Code editing, etc…)? No
Problem description: Copied from: https://developercommunity.visualstudio.com/t/Debug-session-crashes-when-expanding-a-B/1575407
This code demonstrates what happens when inspecting properties under the debugger. The target process crashes on the user.
public class Test : Control
{
public override void OnApplyTemplate()
{
base.OnApplyTemplate();
var be = GetBindingExpression(DataContextProperty);
var p = be.GetType().GetProperty("DynamicConverter", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance);
p.GetValue(be); // throws FailFast
}
}
Actual behavior:
WindowsBase.dll!MS.Internal.Invariant.FailFast(string message, string detailMessage) Line 213 C# WindowsBase.dll!MS.Internal.Invariant.Assert(bool condition) Line 91 C# PresentationFramework.dll!System.Windows.Data.BindingExpression.DynamicConverter.get() Line 493 C#
Expected behavior: No Crash
Issue Analytics
- State:
- Created 9 months ago
- Comments:6 (5 by maintainers)
Top Results From Across the Web
Environment.FailFast Method (System)
FailFast (String, Exception) Immediately terminates a process after writing a message to the Windows Application event log, and then includes the message and...
Read more >net - System.ExecutionEngineException Failure
I've just come across this exception while working on WPF application. VS showed that it happened while notifying property change through ...
Read more >Exception when a WPF window is displayed
FailFast , which throws a System.ExecutionEngineException and terminates the process. A client application is allowed to create one instance of ...
Read more >VS randomly crashes and finally hangs on recovering files
FailFast(string message). Message: System.NullReferenceException: Object reference not set to an instance of an object. at Microsoft.CodeAnalysis.VisualBasic.
Read more >Exception After Obfuscation On Wpf Application
Hello, We have Wpf application which distibuted clients by clickonce technology. We bought SmartAseemply product for obfuscation.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
There is thousands of
Invariant.Assert
calls through the codebase and I thought that crashing is a security precaution (as in my process cannot be trusted anymore, better not touch a thing).The documentation for FailFast says:
Is that information outdated?
Hello @miloush!
The debugger has always treated ExecutionEngineExceptions as a corrupting exception. The only difference with .NET Core is that we do not fire a Managed Debug Assistant for this type of Exception. Otherwise the behavior is identical and the workaround I suggested still applies to both .NET Framework and .NET Core.
ExecutionEngineException is also used for other failures, such as access violations. Because of this, it is not safe to allow execution of managed code. My suggestion is that WPF changes its code to not trigger an ExecutionEngineException while the debugger is attached for internal retail assert failures.