VS2012 Breakpoints are not getting hit

后端 未结 24 1637
小鲜肉
小鲜肉 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:28

    I've recently had the same problem and was smashing my head against the wall.

    The answer turned out to be pretty silly: Somehow my test project got out of sync with the main library project. I was building the debug versions of the test and library, but the test project copied the library from the bin/Release folder. I just recreated the project reference and everything was fixed.

    P.S. It was even criazier: the debugger went inside a library function, but somehow skipped one line in the middle of it.

    0 讨论(0)
  • 2020-12-13 13:29

    In Unit Tests, I was not hitting breakpoints, and realized I was Running the test and not Debugging the test. At the top of the Test Explorer are the options "Run All", "Run Failed", "Run Passed", etc. When you Run a test, breakpoints are not hit. To Debug a test, in the Test Explorer right click on the test or group of tests and select Debug Selected Tests.

    0 讨论(0)
  • 2020-12-13 13:30

    I know from experience that Visual Studio does not have a clear method of debugging services, especially Windows services. Try adding some code to GetStuff to print to a text file, this way you at least know the code is getting hit. When creating services I often fall back on this method for testing.

    0 讨论(0)
  • 2020-12-13 13:31

    First try rebuilding your project by right mouse click the project > Rebuild If that doesn't work, try a clean of the project (right mouse click on the project > clean)

    If that didn't work check this:

    Right mouse click your project
    select [Properties]
    select the [Build] tab
    make sure [Define DEBUG constant] and [Define TRACE constant] are checked
    Click the [Advanced] button at the bottom of the Build tabpage
    Make sure that [Debug Info:] is set to [full]
    Click [OK] and rebuild the project ;-)
    

    Hope that works for you! (step 6 generates the .pdb files, these are the debugging symbols)

    0 讨论(0)
  • 2020-12-13 13:35
    1. Clean the solution and rebuild and also do the start up project.

    2. Can you please have a quick look at the BUILD > Configuration Manager, just to sure what are the configuration properties are set up. If it is development then you might have to adjust the Project Properties -> click advance setting -> change debug info to 'full' in [output tab].

    3. you can also follow step two even it is not development mode

    0 讨论(0)
  • 2020-12-13 13:36

    It turns out this was related to Code Coverage being on.

    Turning it off fixed the issue.

    You can find out how to disable code coverage by following below link

    Disable code coverage

    0 讨论(0)
提交回复
热议问题