Sdílet prostřednictvím


Debugging JScript with the Common Language Runtime Debugger

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.

The common language runtime debugger, dbgclr.exe, is located in the GuiDebug directory of the .NET Framework installation.

To use dbgclr.exe, you must either qualify the program name with the path name or add the path to the search path.

Procedures

To set up debugging for a command line program

  1. Write your program in any editor and save it as text.

  2. Compile the program using the /debug flag. For more information, see /debug.

  3. Start dbgclr, the common language runtime debugger.

  4. From the File Menu of dgbclr, click Open, and then click File.

  5. In the Open File dialog box, open the source file (the file with the .js extension) that you want to debug.

  6. From the Debug menu, click Program to Debug.

  7. In the Program to Debug dialog box, click the ellipses (…) adjacent to the Program pane.

  8. In the Find Program to Debug window, browse to your compiled program (the file with the .exe extension), select it and click Open.

  9. In the Program To Debug dialog box, click OK.

After this setup is complete, you can proceed to the To debug using the Common Language Runtime Debugger section.

To set up debugging for an ASP.NET program

  1. Write your program in any editor and save it as text.

  2. Write the HTML wrapper for the ASP.NET. Be sure to specify that you want to debug the JScript code by including this line in your code:

    <%@page Language=jscript debug=true %>

  3. Open the page in a browser to compile the page.

  4. Start dbgclr, the common language runtime debugger.

  5. From the Tools menu of dgbclr, click Debug Processes.

  6. In the Processes window, select both Show system processes and Show processes in all sessions.

  7. In the Available Processes dialog box, select the ASP.NET worker process that runs that Web application, click Attach, and click Close.

    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).

  8. From the File Menu, click Open, and then click File.

  9. In the Open File window, browse to your source code, select it, and click Open.

After this setup is complete, you can proceed to the To debug using the Common Language Runtime Debugger section.

To debug using the Common Language Runtime Debugger

  1. Move the cursor to the location in the file where you want to set a breakpoint, and press F9.

  2. Repeat the previous step to add more breakpoints.

  3. From the Debug Menu, click Start.

    The program will run until it finds a breakpoint or a run-time error. At this point, several windows will open, allowing you to perform further debugging tasks.

  4. 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, dgbclr 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

Debugging JScript with Visual Studio

Other Resources

Debugger Roadmap