Step 2: Using the DebugContext and ConsoleDebugContext Objects

Commerce Server 2002 provides the DebugContext and ConsoleDebugContext objects to assist site developers in creating and debugging Commerce Server 2002 applications. Developers use these objects to pass properly formed exceptions from within their code and to send trace/warn messages from within the code.

The ConsoleDebugContext object functions are similar to those functions used by Web developers, with the difference that the object functions are designed to be utilized from within programs and executables (.EXEs) instead of being used from within World Wide Web (WWW) pages.

To call the DebugContext.Error() object

  • You use the following code to call the DebugContext.Error() object:

    CommerceContext ctx = CommerceContext.Current;
    ctx.DebugContext.Error("Test Error", "Error Message");
    

To call the ConsoleDebugContext.Error() object

  • You use the following code to call the ConsoleDebugContext.Error() object:

    CommerceContext ctx = CommerceContext.Current;
    ConsoleDebugContext cdc= new 
       ConsoleDebugContext(ctx.DebugContext.DebugMode);
    cdc.Error("Test Error", "Error Message");
    

Copyright © 2005 Microsoft Corporation.
All rights reserved.