VS2012 Breakpoints are not getting hit

后端 未结 24 1656
小鲜肉
小鲜肉 2020-12-13 12:44

I have a class that looks like this:

public class MyService
{
    private MyService(){}
    public static string GetStuff()
    {
        var stuffDid = new          


        
24条回答
  •  春和景丽
    2020-12-13 13:16

    I have a very specific scenario that resulted in the apparent issue of "Breakpoint not being hit".

    Since no other answers here mentioned it, I will add mine in the chance that it will help someone who had the same issue.

    The solution, in my case, was silly, and with as much LINQ as I use I should have figured this out sooner. When running a method that returns an IEnumerable, where the return statements contained within are actually yield return statements, then that method will not be executed when you call it.

    It will actually be executed when you call another method from that IEnumerable object, such as ToList() or Count(). Only then will the method be executed and the breakpoint reached.

提交回复
热议问题