F12 Chooser is a terrific new tool for WinForms applications with Web Browser Control
We previously discussed remote debugging of JS from IE and other processes.
VS2015 is a great tool for remote debugging of applications (or processes). It provides ample opportunity. You can debug applications hosted in QA, testing, integration and other environments where there is no possibility to install Visual Studio. But what if there was a task to debug a memory leak on one of these remote machines? F12 (developer tools in the browser) would help, but what if the leak application is WinForms with a Web Browser Control? Well, not a lot of options. DebugDiag could help identify the leak, but without access to private characters, we may not be lucky. It will be difficult to look for a memory leak in JS. If you were in a similar situation, then you’ll definitely appreciate the new F12Chooser tool that comes with Windows 10. ')
For more detailed information on the F12 developer tools, you can refer to the following resources:
In this simple demo, I use the MDI WinForms application. We will open two forms and debug them. You can download the application itself and the source code. You can download the test application and the code itself. This application is a slightly modified version of the previous demo, mainly a conversion to an MDI application.
Debugging WinForms Hosting Application for Web Browser Control
Run TestApp2.exe
Press File -> NewForm to open a new form.
Open the TestLeak file .html inside it. You can simply drag the file to the browser control and the component will go to this file.
Click File -> NewForm to open another new form.
Open the TestLeak2.html file inside it. You can simply drag the file to the browser control and the component will go to this file.
Press Window -> TileHorizontally to display both windows simultaneously
(Drum roll!) Now open the application C: \ Windows \ SysWOW64 \ F12 \ F12Chooser.exe or C: \ Windows \ System32 \ F12 \ F12Chooser.exe . The choice depends on whether the application is running as a 32-bit or 64-bit process.
Click on the tile that says “ TestLeak.html . You will see the familiar F12 window, and with it we already know very well how to work.
Put a breakpoint in the onclick method on TestLeak. html. In the application, click on the “ Throwanerror ” button and see the breakpoint triggering in the F12Chooser debugger (F12)
Going to the console tab in F12, we can see our error
The great news is the ability to independently debug each form. In other words, you can attach more than one F12Chooser debugger to a single process.
You can do all things familiar to you in F12, for example, change the document mode (document mode) or the user agent string
Debug memory leaks in a WinForms host application for Web Browser Control
Points 1 to 7 are the same as above, and then:
This time we open LeakTest2.html . Go to the memory tab in F12. You will be surprised to see that you cannot analyze memory leaks for an application.
Important note : even though you have IE11 installed, the page is still rendered in IE7 mode. This is the default behavior for the Web Browser Control component. Basically, this is done for backward compatibility for many corporate intranet sites, which can break if rendered in Edge Mode.
So let's change the document mode to Edge and go back to the memory tab.
Press the " Start Profiling " button
Take a snapshot of memory
In the application, press the "Start Memory Leak" button, then after 4-5 seconds - "Stop Memory Leak"
Take another snapshot
We compare two pictures by right-clicking on one of them and selecting the second one, as shown in the screenshot.
If you select one of the strings that flow, you will see that the global array is the root