Debugging JavaScript in a WebBrowser Control from VS2010
You can debug JavaScript executing inside a WebBrowser control embedded in your .NET 4.0 application from VS2010 (Visual Studio 2010), but it takes a little effort.
- Enable Script Debugging (both IE and Other) in Internet Explorer.
- Disable friendly HTTP messages in Internet Explorer.
- Enable Display a notification about every script error in Internet Explorer.
- Modify VS2010 to debug Script from the Attach Process dialog. Please note that you cannot debug both JavaScript (Script) and .NET 4.0 code at the same time. (I don't know why.)
- Add a debugger; statement at the start of your JavaScript.
- Start your WebBrowser-embedded application without debugging (Ctrl-F5).
- When your application hits the JavaScript debugger; statement, select your current instance of VS2010.
- Voilà! You can now debug the JavaScript executing inside the WebBrowser control in your .NET 4.0 application.
(Posted here so I don't forget the steps.)
(This was abstracted from many sources including Silverlight 4 Tools for Visual Studio 2010 Debugging Overview.)
Leave a comment