dotnet / dotnet/wpf

FailFast exception when reflecting over wpf properties

Open
#7,343 6 comments 2 reactions 1 assignee Claimed by @Kuldeep-MS View on GitHub
Investigate
Dominant language
C#
Stars
7.7k
Forks
1.3k
Avg merge
1d 11h
Merged PRs (30d)
61

Description

* .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.

```csharp
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

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.