I call function in .NET using Reflection (Method.Invoke). If an error occurs inside this method and exception is raised, debugger doesn't show actual code but stops at Invoke() call. I can retrieve exception information from InnerException but this is very inconvenient, compared to regular debugging with callstack available and so on. Can methods invoked using Method.Invoke be debugged like regular function calls?
To start debugging, select F5, or choose the Debug Target button in the Standard toolbar, or choose the Start Debugging button in the Debug toolbar, or choose Debug > Start Debugging from the menu bar. The app starts and the debugger runs to the line of code where you set the breakpoint.
To debug a function which is defined inside another function, single-step through to the end of its definition, and then call debug on its name. If you want to debug a function not starting at the very beginning, use trace(..., at = *) or setBreakpoint .
Press F5 to run the program in Debug mode. Another way to start debugging is by choosing Debug > Start Debugging from the menu. Enter a string in the console window when the program prompts for a name, and then press Enter . Program execution stops when it reaches the breakpoint and before the Console.
What you're liking hitting is the "Just My Code" feature. The debugger by default limits debugging to code which is deemed authored by the developer. This reduces a lot of noise that would be present in say debugging a WPF or WinForms launch.
In order to have items like the Exception assistant run for all code you should disable Just My Code.
If all else fails, you can also put something like this into the method that gets invoked:
#if DEBUG
System.Diagnostics.Debugger.Break();
#endif
That will basically "programatically" cause a breakpoint there.
You could also make it slightly better by doing:
if(Debugger.IsAttached)
Debugger.Break();
So that it will only break if you are actually running it in the debugger.
Edit:
On 2nd thought, if you have the code to edit it, then you can probably just stick a regular breakpoint there through VisualStudio. I guess my answer doesn't make sense... sorry :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With