Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I set a breakpoint inside C# PresentationFramework.dll?

This might be a shot in the dark, but, how would I go about setting a breakpoint inside the following internal static method in PresentationFramework.dll?

System.Windows.Documents.TextEditorTyping._ShowCursor()

I've run into a very similar situation to Joe, where I am making a custom auto-complete textbox using a TextBox control and a Popup which contains an ItemsControl. When I have the focus in the text box and the popup shown with StaysOpen="False", and type some characters, the mouse pointer is hidden (through a call to System.Windows.Documents.TextEditorTyping.HideCursor I believe). It is normally re-shown on mouse move, however it appears that the popup handles this event while it is checking whether it should hide or not, so the pointer stays hidden as you move it around the window.

There is a quirk, where on the first key press, the pointer disappears then instantly reappears, then on the second key press, the pointer stays hidden. This suggests that something is calling _ShowCursor(), and I am interested to know what. Hence this post, and the desire to set the breakpoint described above. How do I set that breakpoint?

Regarding my actual problem, the pointer staying hidden once it moves, I hope to solve it either by emulating StaysOpen="False" myself without blocking mouse move events, or to fire mouse move events myself to cause the pointer to reappear. Any other tips on this appreciated.

like image 490
Douglas Avatar asked Jan 16 '10 21:01

Douglas


2 Answers

While you cannot do this with the stock framework (no debug symbols available,) you can get this kind of trickery working with Reflector Pro: http://www.red-gate.com/messageboard/viewforum.php?f=109

Reflector Pro will disassemble the WPF assemblies into .cs source files, and generate it's own debug PDB on the fly - you then then single-step with Visual Studio through the Presentation Framework assembly (and set breakpoints)

good luck!

like image 83
x0n Avatar answered Sep 28 '22 10:09

x0n


I have to recommend you set the breakpoint in the source code file. It is available from the Reference Source, I very strongly recommend the Mass Downloader tool to get it. If you installed it to c:\ReferenceSource then the source code file you need will be available at c:\ReferenceSource\dd\wpf\src\FrameWork\System\Windows\Documents\TextEditorTyping.cs.

One of the great advantages of the reference source over decompiled source is that it contains source code comments. Not all of the source code is available, but very large chunks of WPF are.

John Robbins' install instructions are very good. The only hiccup I had was induced by previously having used the debugging symbols available from the Microsoft debug symbol server. I had to delete the .pdb files that are also available from the reference source from the symbol cache by hand.

like image 27
Hans Passant Avatar answered Sep 28 '22 10:09

Hans Passant