5

I would like to set breakpoint all Convert.ToInt32 lines.

I have tried to replace all Convert.ToInt32 to System.Diagnostics.Debugger.Break(); Convert.ToInt32 but it did not work because some of the Convert.ToInt32 methods are parameter. So I wrote a regex replacement which insert the System.Diagnostics.Debugger.Break(); at the begining of the all Convert.ToInt32 lines. It seems working but is there any easy way of doing this?

ps: I do not think "Debug -> New Breakpoint -> Break at Function" works with System methods.

Update: I have written a small code

class Program
{
    private static void Main(string[] args)
    {
        int test = System.Convert.ToInt32("x");

        System.Console.Write(test);
    }
}

I have changed my "Tools -> Options -> Debugging" settingsTools -> Options -> Debugging

But it is still not working enter image description here

ogun
  • 1,314
  • 2
  • 16
  • 40
  • Yes, they are similar but the answer is not solve my problem. – ogun Jun 08 '13 at 08:19
  • I am sorry if i am not understanding you,thats why i ask....cant you just click the left grey bar(breakpoit bar) in the code editing window? – terrybozzio Jun 10 '13 at 03:10
  • @terrybozzio :) of course i can click the left grey bar but i have dozens of Convert.ToInt32 lines and I want to set breakpoint all of these lines. – ogun Jun 10 '13 at 11:03

1 Answers1

2

Turn off the "Enable Just My Code" setting in the Debugging configuration and Enable .net framework source stepping. Now you can add Break at Function option

Damith
  • 62,401
  • 13
  • 102
  • 153
  • I have done the above settings but it does not work. I have written a small program for this issue but "break at function" does not set breakpoint for System.Convert.ToInt32... class Program { private static void Main(string[] args) { int test = System.Convert.ToInt32("x"); } } – ogun Jun 08 '13 at 08:17
  • I have tested and working fine for me, thats why posted as answer. – Damith Jun 08 '13 at 08:47
  • I'm not sure but it can be related with http://connect.microsoft.com/VisualStudio/feedback/details/783679/net-framework-source-debugging-does-not-work – ogun Jun 08 '13 at 09:00
  • I would also check `Enable address-level debugging` and `Show disassembly if source is not available` in the Debugging Options dialog – Sebastian Jun 09 '13 at 13:43