11

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?

JaredPar
  • 673,544
  • 139
  • 1,186
  • 1,421
PICyourBrain
  • 9,386
  • 26
  • 87
  • 133

12 Answers12

11

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

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

Try the scenario again.

JaredPar
  • 673,544
  • 139
  • 1,186
  • 1,421
10

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

sebagomez
  • 9,029
  • 6
  • 48
  • 84
Paul N
  • 116
  • 1
  • 3
6

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.

Bo Persson
  • 86,087
  • 31
  • 138
  • 198
JanBorup
  • 4,593
  • 1
  • 27
  • 16
  • This did it for me! The debugger only stopped at branches in my code (returns and if statements), which is actually very logical, come to think of it; This alignes with the control flow of my program. Switching to debug mode, fixed it! – Don Jun 09 '16 at 13:45
3

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

3

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.

Ken
  • 31
  • 1
2

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.

svick
  • 214,528
  • 47
  • 357
  • 477
David Goshadze
  • 1,419
  • 12
  • 16
0

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.

stuartdotnet
  • 2,600
  • 3
  • 31
  • 35
0

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.

Marko Bonaci
  • 5,271
  • 2
  • 28
  • 46
0

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'

John M
  • 53
  • 5
0

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.

0

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.

0

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.

razzy
  • 198
  • 1
  • 9