Though the ability to debug Javascript in Visual Studio is great, perhaps you’ve noticed this feature can grind your development/debugging imageto a near halt.  Well, here’s what you need to do if you wish to be productive again.

image

Enable the following IE setting and you too can save yourself hours of debugging time:

IE  > Tools > Internet Options > Advanced > Browsing > Disable Script Debugging (Internet Explorer)

That’s it. What’s this option do?  It tells Visual Studio to stop generating and rendering massive amounts of Anonymous Code files to the Script Window.  In my opinion, MS really blew it when they implemented this feature.  They obliviously didn’t consider highly-javascripted applications in their use case.  Actually, I didn’t run up against this constraint until my current project so maybe this is not a typical developer issue.  All the same, enable/disable script debugging at your own risk and on your own time.

Update 4/16/2009 – VS 2008 and IE8: If you have been keeping up with this post’s comments, you may have come to realize that Visual Studio 2008 shipped with a feature to automatically enable script debugging when starting IE8 from Visual Studio. In other words, if you are using VS 2008 and IE8, there is no longer a way to toggle script debugging through tweaking your IE options. However, workarounds are available:

Open a new command prompt (start->run, cmd.exe). If you are on a 64-bit computer this needs to be a 32-bit prompt (start->run, c:\windows\syswow64\cmd.exe)

reg add HKLM\SOFTWARE\Microsoft\VisualStudio\9.0\AD7Metrics\Engine\{F200A7E7-DEA5-11D0-B854-00A0244A1DE2} /v ProgramProvider /d {4FF9DEF4-8922-4D02-9379-3FFA64D1D639} /f

If you are using Visual Web Developer Express, replace ‘VisualStudio’ with ‘VWDExpress’:

reg add HKLM\SOFTWARE\Microsoft\VWDExpress\9.0\AD7Metrics\Engine\{F200A7E7-DEA5-11D0-B854-00A0244A1DE2} /v ProgramProvider /d {4FF9DEF4-8922-4D02-9379-3FFA64D1D639} /f

If you want to restore your computer so that you can debug scripts again:

reg add HKLM\SOFTWARE\Microsoft\VisualStudio\9.0\AD7Metrics\Engine\{F200A7E7-DEA5-11D0-B854-00A0244A1DE2} /v ProgramProvider /d {170EC3FC-4E80-40AB-A85A-55900C7C70DE} /f

The link above provides alterative paths to disable script debugging if you have Silverlight 2 tool installed and an option to suppress the anonymous script blocks while still allowing script debugging. I tested the latter option and though it didn’t work for me, you might have better luck. 

A big thanks to Henning (see comments) for helping to track this down.

20 Comments to “Visual Studio and Anonymous Code”

  1. [...] Visual Studio and Anonymous Code – Ben Griswold [...]

  2. I’m not sure how an IE setting tells Visual Studio what to do. In any case, it does not work for me in IE8.

  3. Ben Griswold says:

    Sorry it isn’t working for you, Steve. It’s working for everyone who’s tried in my shop (6 developers.) Actually, once we disable script debugging in IE, we receive a warning the next time we launch VS and we’re asked if we wish to re-enable. We’re all running IE7, but I wouldn’t think this would change with IE8. All the same, thanks for the feedback and thanks for trying.

  4. Henning says:

    Hello,

    For me its also not working with IE8. I used it with IE7 quite often and it works well. I think its a bug and IE8 is maybe not “linked” to VS2008.

  5. Henning says:

    Here it is explained why script debug disable doesnt work with IE8:
    http://blogs.msdn.com/webdevto.....h-ie8.aspx

  6. Ben Griswold says:

    @Henning – Thanks for the IE8 help and thanks for the link.

  7. Henning says:

    No problem we´re all on the same side :)

    If someone does have a solution to force disable script debugging please write it down!

    Until know I recommend to all my collegues not to install IE8 because it slows down our development really heavy.

    There are maybe workarounds to use portable versions of IE7 but this can´t be the one and only solution…

    Thank you very much.

  8. Ben Griswold says:

    @Henning Absolutely. If/when an answer surfaces, I will be sure it gets included in this post and comments.

  9. Henning says:

    Found the solution!

    http://blogs.msdn.com/greggm/a.....8-ie8.aspx

    I first tried the anonymous code workaround but this didn´t work for me. But the cmd regcommand did the trick.

  10. Ben Griswold says:

    @Henning Thanks for staying on top of this and reporting back to us. I will test and update this post with my findings as well. Thanks again!

  11. Rob Young says:

    This is really slowing down my development! Hopefully this will help! Thanks.

  12. Han says:

    Thank you alot.

  13. cyn-tacks says:

    Ben,

    This is one of those things that has bothered me forever! Finally it reached the “google level” where I was so fed up I “google’d” it. Thankfully I found your website, awesome!

  14. Ben Griswold says:

    Really glad to help you out, @cyn-tacks. This was a terrible bother for me as well.

  15. songdejc says:

    Ben,

    Thank you very much. This issues was bugging me for a very long time.
    At first, I thought it’s a 3rd party component bug.

  16. Clemente says:

    Third time is a charm.

  17. How can I change to fluid width in the New Blogger Template Designer?

  18. I was recommended this web site via my cousin. I am not positive whether or not this publish is written through him as nobody else understand such targeted about my trouble. You are amazing! Thank you!

  19. realtor st louis says:

    I was suggested this web site through my cousin. I am no longer positive whether this post is written by him as no one else recognise such distinct about my problem. You are wonderful! Thanks!

  20. Just desire to say your article is as astounding. The clearness to your put up is just nice and that i can suppose you’re an expert in this subject. Well together with your permission allow me to grasp your RSS feed to keep up to date with drawing close post. Thanks 1,000,000 and please keep up the enjoyable work.