VS2012 Breakpoints are not getting hit

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

    This one's pretty obscure :

    Make sure you don't have two virtual directories with different App Pools pointing to the same physical location on your harddrive. During development this is something that can sometimes happen for testing, or by mistake.

    I'm not 100% clear on the technicalities but I had two AppPools and two virtual directories and no breakpoint was ever hit because I presume the physical path was somehow mapped in IIS/Visual Studio to the other apppool and not the one that was actually executing.

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

    It could be beacuse you are only debugging 1 project not both Test and Core

    You can set VS to debug mutiple projects at once, you can do this by right-click your solution > Properties > Common Properties > StartUp Project

    Here you can set "Multiple Startup Projects" enter image description here

    Just set both Core and Test to start. This may solve your issue.

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

    Your code indicates a "service", which could be running as a separate process. If that's the case you can have your assembly loaded, so breakpoints would be solid red circles but another copy of the assembly, running in a separate process is actually handling the requests.

    • check Task Manager for possible offenders (processes that may be hosting your service). Kill them while debugging to confirm the calls fail.
    • Try using Debugger.Break();
    • Create a debug log file, upon loading output to the log the entry process and assembly names. Make sure your log is either a different file each time to avoid async access issues.
    0 讨论(0)
  • 2020-12-13 13:19

    I have the same issue. Maybe my solution will help you to solve your problem. Just in "Attach to Process" for option "Attach to" select value "Avtomatic: Native code". Best regards.

    Image

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

    Just make sure that you have build your assembly with the debugger symbols.

    This option has to be filled with "full":

    Right-Click your project containing your code file with the break points not getting hit. Choose "Properties".

    After project properties have been opened, choose "Build" tab. Watch out for the "Advanced..."-Buttom at the bottom of the tab page. (Within the "Output"-Group")

    Click this button and choose "full" for the "Debug info" property. This should be a reason for breakpoints not getting hit. Visual studio uses the symbols saved in the pdb-files to find the exact position of the break point. If these files are not created, no breakpoints are hit. Maybe you disabled the creation of these files in order to tidy up your project file structure. This was a situation I recognized that I need these files.

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

    Maybe your Test project is referencing an older Core binary, rather than the Core (source code) project?

    Try re-adding the reference in your Test project:

    Go to your Test project and remove the reference to the Core project.

    Now select the References folder and right click it and select the menu option to add a new reference. When in the Reference Manager dialog, make sure you are selecting Solution and then Projects on the left. Then in the middle of the Reference Manager dialog, select (check) the Core project.

    Try debugging again and see if that helps.

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