ComponentSpace Professional .NET and ActiveX components for developers
ComponentSpace Home | Products | Downloads | Support | Purchase | Services | About Us
 

Code Samples

The product includes numerous VB.NET and C# ssample applications. All samples include complete source code. For more detailed sample code please refer to the sample applications.


Using the Trace Listeners

Listing 1 demonstrates using the trace listeners. The standard System>Diagnostics.Trace class is used to write trace entries. The application's configuration file must be set up for one or more of the trace listeners to record the trace information.



' Requires trace listeners to be configured in the application's .config file.
traceCount += 1
System.Diagnostics.Trace.WriteLine("This is test #" & traceCount & ".")
									

Listing 1 Using the trace listeners


Cyclic File Trace Listener Output

Listing 1 shows some sample output saved to a cyclic file by the cyclic file trace listener. In the trace entries, only the last field was written by the calling application. The trace listener automatically included all other fields. The standard System>Diagnostics.Trace class is used to write trace entries.

The date and time, process and thread identifiers, and the class and method name of the caller are automatically recorded by the trace listener.



07/04/2003 9:24:03 AM, 14220/12972, MyClass.MyMethod, This is test #1.
07/04/2003 9:24:07 AM, 14220/12972, MyClass.MyMethod, This is test #2.
07/04/2003 9:24:08 AM, 14220/12972, MyClass.MyMethod, This is test #3.
07/04/2003 9:24:11 AM, 14220/12972, MyClass.MyMethod, This is test #4.
07/04/2003 9:24:15 AM, 14220/12972, MyClass.MyMethod, This is test #5.
									

Listing 1 Cyclic file trace listener output