Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Prevent VS Debugger from stopping inside a specific method

Is there an option/attribute/... that prevents VS's debugger from stopping a debugging session inside a specific method? I'm asking because I'm suffering from the BSoD that the class Ping of .NET 4.0 sometimes triggers. See Blue screen when using Ping for more details.

private async Task<PingReply> PerformPing()
{
    // Do not stop debugging inside the using expression
    using (var ping = new Ping()) {
        return await ping.SendTaskAsync(IPAddress, PingTimeout);
    }
}

1 Answers

DebuggerStepthrough

Fun fact you can set it at a method level or a class level.

Instructs the debugger to step through the code instead of stepping into the code. This class cannot be inherited.

Tested with

using System;
using System.Diagnostics;

public class Program
{
    [DebuggerStepThrough()]
    public static void Main()
    {
        try
        {
            throw new ApplicationException("test");
        }
        catch (Exception ex)
        {
            Console.WriteLine(ex.ToString());
        }
    }
}

And the debugger didnt stop in the MAIN method

like image 171
gh9 Avatar answered Dec 09 '25 21:12

gh9