Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual Studio 2010 script debugger doesn't work for me

I just installed VS 2010 Beta 2 and wanted to play with an ASP.NET MVC 2 project. I simply added some script (alert('hello');) into the Home controller's index.aspx view, and I can see it executing. When I try to set a breakpoint, however, it never gets hit. I also tried to use the "debugger" keyword, and when I do, I get a disappointing "there is no source code available for the current location" message. I also get this message when I try to independently attach to an IE process where my app is running.

What do I need to do to get a friendly script debugging experience? (I have successfully used Firebug to debug this, but for some reason I prefer the VS debugger.)

Here are some details of my configuration:

  • I am launching my stuff in VS 2010 Beta 2.
  • IE8 version 8.0.7600.16385 is my default browser.
  • The "Disable script debugging (Internet Explorer)" advanced option is unchecked.
  • The "Disable script debugging (Other)" option is unchecked.
  • In my ASP.NET MVC 2 project's "web" properties tab, the ASP.NET debugger is checked. All others are unchecked.
  • Visual Studio 2008 script debugging seems to work just fine.
like image 639
Chris Farmer Avatar asked Oct 26 '09 16:10

Chris Farmer


People also ask

Why are my breakpoints not hitting?

If a source file has changed and the source no longer matches the code you're debugging, the debugger won't set breakpoints in the code by default. Normally, this problem happens when a source file is changed, but the source code wasn't rebuilt. To fix this issue, rebuild the project.

How do I debug a Visual Studio script code?

To run or debug a simple app in VS Code, select Run and Debug on the Debug start view or press F5 and VS Code will try to run your currently active file. However, for most debugging scenarios, creating a launch configuration file is beneficial because it allows you to configure and save debugging setup details.


2 Answers

The debugger cannot debug both Silverlight code and Script code at the same time, if the Silverlight debugger is selected JavaScript debugging is switched off.

  1. Go to the Project's Properties (Alt+Enter).
  2. For a Web Site Project: Select "Start Options". Or for a Web Appliction: Go to the Web tab and at the bottom you will see the Debuggers option.
  3. Check that the Silverlight checkbox is NOT ticked if you want to be able to debug JavaScript. (It is unfortunate that the UI here is not clear about this side effect.)
like image 85
Mister Cook Avatar answered Oct 02 '22 18:10

Mister Cook


I was having the same issues. I was not able to get the IDE to even break at a breakpoint set inside a script tag. However when I added "debugger;" as the first line in the script tag was able to get the IDE to respond but then only to say that the disassebly was not availble.

However, I was able to click on the debug tools like "step into" and "step over". When I did this the IDE did progress into some of the external scripts that I am using (JQuery and Google Maps). So I took the JavaScript code block out of the view and put it into a separate .js file in the "Content" folder. Then I added a script tag to reference this new .js file (url = "/Content/Test.js").

It worked... a little bothersome that you have to go through this effort but maybe there is something to be said for JavaScript not being included directly in a view. I hope this is a bug they intend to fix.

like image 32
Ryan Pedersen Avatar answered Oct 02 '22 18:10

Ryan Pedersen