Skip to content

Debug.Assert no longer shows a dialog prompt #3346

@RussKie

Description

@RussKie
  • .NET Core Version: .NET Core 3.1 onwards

  • Have you experienced this same bug with .NET Framework?: No

Problem description:

System.Diagnostics.Trace.Assert and System.Diagnostics.Debug.Assert no longer trigger a dialog prompts in desktop apps. Instead apps silently silently crash unless have a debugger attached.

As discussed in dotnet/runtime#40512, the assert behavior was changed in dotnet/coreclr#20764, and no longer raises a dialog.
https://github.com/dotnet/corefx/blob/master/src/System.Diagnostics.Debug/tests/DebugTestsUsingListeners.cs#L248-L303 illustrates how to implement a custom trace listener, which may act as a basis for a fix.

Expected behavior:

No crash, and assertion dialog must appear after assert.

Minimal repro:

  1. Create new WPF Core project.
  2. Put System.Diagnostics.Debug.Assert(false, "test"); anywhere in the code, for example:
    protected override void OnActivated(EventArgs e)
    {
        System.Diagnostics.Debug.Assert(false, "test");
    }

Metadata

Metadata

Assignees

Labels

BugProduct bug (most likely)

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions