Why doesn't VS2010 debugger stop at my breakpoints?

可紊 提交于 2019-11-30 18:18:21
Paul N

To solved this problem by creating a config file for the application which is using the component to debug with the following data:

<?xml version="1.0"?>
<configuration>
  <startup>
     <supportedRuntime version="v2.0.50727"/>
  </startup>
</configuration>

With this file you tell the debugger to use the right runtime version for debugging (it seems the debugger uses version 4.0 by default).

My first check would be to disable "Just My Code"

  • Tools -> Options
  • Debugger
  • Uncheck "Enable Just My Code"

Try the scenario again.

JanBorup

I have a tried a whole day to find out why I couldn't debug my visual studio 2012 console application, and the answer was embarrassing.

I was running it in "RELEASE" mode.

Sometimes the obvious is the hard to find.

Close the Visual Studio IDE and Open it. Now it will work. For me it also face the same issue. I used this way to overcome

I had a "Rebuilt" VS2013 project that I couldn't debug (no symbols). Finally, I saw Optimization was checked (Project->Properties->Build). I unchecked it and Rebuilt. Symbols loaded finally. My two cents, only use (compile) Optimization when absolutely necessary.

David Goshadze

While I can't answer why it happens, I can provide you with workaround.

  1. Include

    using System.Diagnostics;
    
  2. At the very beginning of your code (Class constructor for instance) place the following lines:

    #if (DEBUG)
                    while(!Debugger.IsAttached);
                    Debugger.Break();
    #endif
    
  3. Start debugging.

  4. Menu Tools→Attach to Process
  5. Attach to your process.

breakpoint should trigger in your code. Other breakpoints should trigger as well.

Could be a number of reasons. Usually it's because you're trying to debug against the wrong version.

These actions work about 80% of the time.

  • Get the latest code
  • Clean
  • Rebuild
  • Restart IIS
  • Try again

If no good, go to Debug > Windows > Modules and if the relevant dll is there, right click it and load symbols.

If it's not in the list, try running the code anyway. Sometimes even though it says the breakpoint will not be hit, it's only because the dll is not loaded until you enter a scenario that needs it. Try the scenario that depends on the dll, and it may just hit the breakpoint anyway.

Oh one more idea, restart your browser. You might have something cached from an older dll.

If the reason is wrong .NET runtime version (which was my problem), instead of creating configuration file you can simply choose the right version in the Attach to process dialog.

In the dialog, next to Attach to click on Select and switch from Automatically... to Debug these code types where you should check the right version.

If this was your problem also, then you probably had "Symbols not loaded" message on your breakpoints. Immediately after selecting the right version you should see that this error is no longer reported.

For me it was fixed by:

  1. Open the project properties is VS2010

  2. Goto Compile -> Advanced Compile Options

  3. Change 'Generate debug Info' from 'None' to 'Full'

The problem could be your browser is using a cached version of the page, you are working with. Try to add som nonsense extra querystring in your adress line of the browser f.x. add ?NONSENSE=1234 This forces the browser to use a new version of the web page since it does not know if the page should look different with this Query in the end. Next time use ?NONSENS=1235.

I had a problem with misplaced breakpoints in my native c++ code. The reason was I had been editing the code so some line ends in the code was not \r\n. It was not possible to see in the code unless you searched for \r\n. After inserting the proper line ends \r\n the debugger worked.

I encountered the similar issue but its in a CLR project. I had some old c++ syntax in the CLR project. For me after I enabled 'Use managed compatibility mode' in Tools>options>Debugging>General it started to hit the break points.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!