I wish to set a breakpoint on the System.Threading.SynchronizationContext::SetSynchronizationContext static method so I can find out when the synchronization context is being set.
However I can’t find how to set a breakpoint in a method I don’t have the source code to.
(This should be easy!, but when I try to set the breakpoint on a method from the breakpoints window it does recognise the me开发者_开发技巧thod.)
Click Debug, Windows, Breakpoints, click New, Break at function, enter System.Threading.SynchronizationContext.SetSynchronizationContext
, and click OK.
It will give you a warning, which you should ignore. I tried it, and it does work.
Edit by Ian Ringrose
I also had to turn off the "Enable Just My Code" setting in the Debugging configuration.
Start Visual Studio 2008 and bring up Tools > Options > Debugging > General. If you are running under the Visual Basic Profile, you will need to check the box on the lower left of the Options Dialog marked "Show All Settings" before continuing (other profiles won't have this option). Set the following settings: Turn OFF the "Enable Just My Code" setting
It is possible to debug the .NET framework classes. All you have to do, is setup VS.NET so that it is able to download the debug symbols for the .NET framework from one of Microsoft's servers.
You won't be able to set a breakpoint inside a .NET method though, but, you will be able to step into another method of the .NET framework, and while debugging, and once you've stepped into that method, (and VS.NET has opened the file that contains the SetSynchronizationContext method), you'll be able to set a breakpoint on that method.
For information on how to setup VS.NET so that you can debug the .NET framework, click here
精彩评论