Debugging JScript with Visual Studio
Some JScript programs are designed to run from the command line, while others are designed to run in an ASP.NET page. The type of program influences the debugging method.
Procedures
To set up debugging for a command line program
Compile the program that you intend to debug using the /debug flag. For more information, see /debug.
Start Microsoft Visual Studio.
From the File Menu, click Open, and then click Project.
In the Open Project dialog box, browse to your compiled program (the file with the .exe extension), select it and click Open.
From the File Menu, click Open, and then click File.
In the Open File dialog box, browse to your source code (the file with the .js extension), select it and click Open.
From the File menu, click Save All.
Choose a name and location to save your new project.
After this setup is complete, you can proceed to the Debugging using Visual Studio section.
To set up debugging for an ASP.NET program
Start Microsoft Visual Studio.
Open the ASP.NET file that you intend to debug.
Set the debug flag to true in the @page directive. For example:
<%@page Language=jscript debug=true %>
Open the page in a browser to compile the page.
From the Visual Studio Tools menu, click Debug Processes.
In the Processes dialog box, select the Show system processes and Show processes in all sessions options.
In the Available Processes pane of the Processes dialog box, select the ASP.NET worker process that runs that Web application, and click Attach.
By default, the worker process is aspnet_wp.exe for IIS 5.x (on Windows 2000 and Windows XP), and w3wp.exe for IIS 6.0 (on Windows Server 2003).
In the Attach to Process dialog box, select Common Language Runtime and click Ok.
In the Processes dialog box, click Close.
After this setup is complete, you can proceed to the Debugging using Visual Studio section.
To debug using Visual Studio
In the Visual Studio IDE, open the file that you intend to debug, as described in either of the above setup sections.
Move the cursor to the location in the file where you want to set a breakpoint, and press F9.
Repeat the previous step to add more breakpoints.
From the Debug menu, click Start.
The program will run until it encounters a breakpoint or produces a runtime error.
At this point, several windows will open, allowing you to perform further debugging tasks. For more information, see Debugger Roadmap.
To stop debugging but leave the program running, from the Debug menu, choose Detach All.
Otherwise, the program will be terminated when you stop debugging.
Remarks
When debugging program compiled from the command line, Visual Studio rereads the compiled program each time you start debugging. Consequently, you can modify your JScript code and (after recompiling the code) check the effect of those changes.
See Also
Tasks
Writing JScript Code with Visual Studio
Concepts
Building from the Command Line
Building from the Command Line
Debugging JScript with the Common Language Runtime Debugger