I've got a weird situation where something is setting the TopMost property of the main MDI form to true. After much trial and error we're pretty sure this must be coming from a third party library but it's not in any places that we would expect.
It would be VERY easy to fix this if we could just set the application to break in the debugger whenever this property was set. However this property is defined by the WinForms libraries so we can't just put a breakpoint in there.
For cases where you're working with a library that you don't have the source code for this would be invaluable but I fear there is no solution to this problem since Data Breakpoints are not supported for managed languages (as far as I know).
So, in C# is there a way that you know of to break when a property gets changed when you don't have access to place a breakpoint in the setter? This could easily solve many edge case issues where things get changed for reasons you can't anticipate.
It is possible to set breakpoints on code you don't own. Since TopMost
is a property, all you have to do is putting a breakpoint on the setter.
Just open the "breakpoints" panel in Visual Studio (Debug -> Windows -> Breakpoints), click on "New -> Function Breakpoint" then type:
System.Windows.Forms.Form.set_TopMost
Run your application (make sure the symbol are loaded), and profit.
Note that you also need to make sure that "Just my code" is disabled. Go in Tools -> Options -> Debugging -> General, and uncheck "Enable Just My Code".
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