Why doesn't VS2010 debugger stop at my breakpoints?
Asked Answered
D

12

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?

Delphadelphi answered 23/8, 2010 at 20:28 Comment(2)
Do you have symbols present, and are you sure the source is the same as the assembly you are debugging? Did you rebuild?Determinative
If I change the source I see the change present in the output. Yes I have tried rebuilding.Delphadelphi
A
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).

Accompanist answered 9/3, 2011 at 15:42 Comment(0)
C
10

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

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

Try the scenario again.

Cottrill answered 23/8, 2010 at 20:32 Comment(0)
A
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).

Accompanist answered 9/3, 2011 at 15:42 Comment(0)
K
7

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.

Kress answered 18/12, 2012 at 22:11 Comment(1)
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!Sidewalk
A
3

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

Aviatrix answered 16/4, 2015 at 8:58 Comment(0)
S
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.

Spontaneous answered 3/9, 2015 at 21:11 Comment(0)
G
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.

Gapin answered 24/8, 2010 at 13:21 Comment(0)
T
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.

Threephase answered 30/1, 2013 at 2:34 Comment(0)
R
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.

Ridenhour answered 16/4, 2013 at 8:4 Comment(0)
M
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'

Meredithmeredithe answered 21/8, 2013 at 3:2 Comment(0)
S
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.

Susiesuslik answered 24/11, 2014 at 9:58 Comment(0)
D
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.

Display answered 31/3, 2016 at 10:41 Comment(0)
T
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.

Theosophy answered 21/7, 2016 at 8:12 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.