Microsoft Visual Studio 2012 cannot set breakpoint in c# file

后端 未结 6 2039
面向向阳花
面向向阳花 2021-02-18 22:32

I have Microsoft Visual Studio Professional 2012 installed, version 11.0.60610.01 Update 3.

When debugging a c# (.cs) file Visual Studio gives me the following message

6条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-02-18 23:25

    Well, sheesh...for people as dumb as me, here's one more thing to consider:

    You can put breakpoints on the curly braces at the start or close of a method, and you can put breakpoints on any line that is doing something (e.g. assigning a value or calling a method). However, you can't put a breakpoint on a line that is only declaring a variable or otherwise "doing nothing."

    E.g. I had a method:

    public IEnumerable GetList()
    {
        int distance;
        var otherVar = SomeValue;
    }
    

    I was trying to put the breakpoint on the first line with int distance;, which is something that works fine in other IDEs, but that doesn't work in VS. I had to go up to the brace or down to the next line with the assignment in order to get the breakpoint to set.

    5 minutes of my life wasted, that I'll never get back, trying to debug a non-issue ;-p

提交回复
热议问题