Tips and Tricks for Debugging

Summary

This chapter covers interactive source-code debugging, the information needed by the debugger, and how to instrument your applications.

First I describe some core features of the Visual Studio .NET debugger that help simplify the task of developing Web services. One of the unique requirements for debugging Web services is strong support for remote debugging. The key features that Visual Studio .NET provides for supporting remote debugging include these:

  • Visual Studio .NET automatically attaches to the remote ASP.NET process hosting the Web service.

  • It allows you to configure the target server to allow remote debugging.

  • It can display a logical call stack that spans multiple threads.

  • It ensures that you get a complete call stack when an unhandled exception occurs within your application.

Next I explain what information the debugger needs in order to perform essential tasks. Specifically, it needs information for creating a readable call stack; that information is contained within the metadata in the module that contains the types that compose the call stack.

Interactive source-code debugging requires mapping between the original source code and the machine code generated by the JIT compiler. One half of the mapping, between the source code and the MSIL, is provided by the program database (.pdb) file. The other half of the mapping, between the MSIL and the native machine code, is provided by the tracking information generated by the JIT compiler.

The tracking information is generated when the MSIL is JIT compiled into native code. Because the compiled native code is unaffected by the generation of the tracking information, the slight performance penalty associated with tracking occurs only during application warm-up.

You can also specify whether the JIT compiler generates optimized code. If optimization is turned on, you might experience a loss of fidelity between the compiled machine code and the original source code. Because you incur a significant performance hit as a result of generating machine code that is not optimized, I suggest that you enable optimization for release builds.

Finally I explain the various technologies provided by .NET for instrumenting your Web services and the client applications that interact with them. I explain the similarities and differences between the Debug and Trace classes and show you how to add and remove listeners at compile time as well as at run time.

I also explain how to leverage the Event Log for communicating important information to the system administrator, and I demonstrate how to use performance counters to publish real-time information about the current state of the application.



Building XML Web Services for the Microsoft  .NET Platform
Building XML Web Services for the Microsoft .NET Platform
ISBN: 0735614067
EAN: 2147483647
Year: 2002
Pages: 94
Authors: Scott Short

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net