views:

6180

answers:

7

I'm working on a .net 3.5 website, with 3 projects under one solution. I'm using jquery in this project. I'd like to use the visual studio javascript debugger to step through my Javascript. If I set a breakpoint in any of the .js files I get a warning that says "The breakpoint will not currently be hit. No symbols have been loaded for this document."

Anyone have any ideas on how to fix this? I'm guessing that VS is having some trouble parsing through some of the jquery code. I will try to replace the minimized version of jquery.js with the expanded version, but I don't think that will fix it.

A: 

You have to wait for the IDE to parse the javascript - just wait a while and you should see the js code change color and you will be able to add breakpoints.

redsquare
+2  A: 

I would suggest using FireBug for JavaScript debugging. Give it a spin :)

roosteronacid
A: 

I sometimes have this problem with external js files - it is caused as a result of the browser cache holding onto an old copy of the file. Forcing a refresh of the page linking to the javascript solves the issue in this case.

Of course, make sure your debugger is attached to the correct browser process. ;)

Raithlin
And set to debug Script!
Slace
+2  A: 

Make sure you turn on script debugging in your internet options. And if you think it's on, double check it.

Will
+3  A: 

I was experiencing the same behavior in Visual Studio 2008 and after spending several minutes trying to get the symbols to load I ended up using a workaround - adding a line with the "debugger;" command in my JavaScript file.

After adding debugger; when you then reload the script in IE it'll let you bring up a new instance of the script debugger and it'll stop on your debugger command let you debug from there.

In this scenario I was already debugging the JavaScript in FireBug but wanted to debug against Internet Explorer as well.

Ian Robinson
+3  A: 

I finally found the answer to this I think.

When you attach your debugger to the iexplore.exe process, you need to make sure you select "Script" as one of the debugging choices.

It's the button in a red box here: Screenshot of Select Button in Attach to Process Window

Then on the next screen, choose Script: Screenshot of Select Code Type window

This will warn you that you cannot debug Managed and Script at the same time, but that should be fine because your managed code is your server code and you attach to the web process (aspnet or w3wp) instead.

You'll know you did it right because VS 2008 will load ALL the script documents pertaining to that page (inline stuff, eval stuff, etc.) in Solution Explorer.

You'll have full access to the DOM, the immediate window will work, etc. It's pretty slick.

CubanX
A: 

I had the same issue but solved it by changing my browser settings in Internet Explorer. Go to Tools > Internet Options, select the Advanced Tab, then make sure that both "Disable Script Debugging (Internet Explorer)" and "Disable Script Debugging (Other)" are unchecked.

Also, I needed to set Internet Explorer as my default browser, which is normally set as Firefox. To do that, in Visual Studio just right click on any browseable file in your solution explorer and select "Browse With..." Select Internet Explorer and click "Set as Default".

I'm not sure if there's a way to get debugging running with other browsers, but it wouldn't surprise me if VS only plays nice with IE.

Also, you may need to do "Attach to process" and add IExplorer.exe to get the debugger to start.

Paranoid Kid