Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I debug javascript code in a webbrowser control in VS 2012

I would like to know if I can use the debugger in VS 2012 for javascript code in a webbrowser control for a winform app. I'm not talking about debugging in a web browser such as IE as this is not how I am running the code. I have tried placing "debugger;" in my javascript code but it still runs through it and does not stop.

Here is an example of how I am using it.

function addDeleteButton(poly, imageUrl) {
        debugger;
        var path = poly.getPath();
        path["btnDeleteClickHandler"] = {};
like image 389
Programmer Avatar asked Dec 07 '22 01:12

Programmer


1 Answers

Thanks to Borys Generalov for this answer!

The instructions for this can be found here http://blogs.perl.org/users/mark_leighton_fisher.

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.

  1. Enable Script Debugging (both IE and Other) in Internet Explorer.
  2. Disable friendly HTTP messages in Internet Explorer.
  3. Enable Display a notification about every script error in Internet Explorer.
  4. 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.)
  5. Add a debugger; statement at the start of your JavaScript.
  6. Start your WebBrowser-embedded application without debugging (Ctrl-F5).
  7. When your application hits the JavaScript debugger; statement, select your current instance of VS2010.
  8. Voilà! You can now debug the JavaScript executing inside the WebBrowser control in your .NET 4.0 application.

This needs to be done regardless of ever using IE when debugging or running your code in VS 2012.

like image 167
Programmer Avatar answered Dec 28 '22 10:12

Programmer