Why doesn't VS2010 debugger stop at my breakpo

2019-04-05 02:30发布

I am working on a C#.NET class library project in VS2010. In my project settings -> debug settings, I have the project set to start an external program (C:\Windows\SysWOW64\wscript.exe) which runs a very simple jscript file (test.js). The script simply creates an instance of the class and calls one of it's methods.

The problem is when I start debugging, VS2010 does not stop at any of my breakpoints. If I open up the exact same project in VS2008 it does stop at the break points. Is there a new setting somewhere that is preventing the breakpoints from being hit? Has anyone else ran into this issue?

12条回答
淡お忘
2楼-- · 2019-04-05 02:50

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

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

Try the scenario again.

查看更多
SAY GOODBYE
3楼-- · 2019-04-05 02:54

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.

查看更多
对你真心纯属浪费
4楼-- · 2019-04-05 02:55

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).

查看更多
ゆ 、 Hurt°
5楼-- · 2019-04-05 02:56

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.

查看更多
Ridiculous、
6楼-- · 2019-04-05 02:58

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'

查看更多
冷血范
7楼-- · 2019-04-05 03:00

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.

查看更多
登录 后发表回答