TraceSource Constructor (String)

Note: This constructor is new in the .NET Framework version 2.0.

Initializes a new instance of the TraceSource class, using the specified name for the source.

Namespace: System.Diagnostics
Assembly: System (in system.dll)

public TraceSource (
	string name
public TraceSource (
	String name
public function TraceSource (
	name : String



The name of the source, typically the name of the application.

Exception typeCondition


name is a null reference (Nothing in Visual Basic).


name is an empty string ("").


The recommended practice is to use the name of the application for the source name.

The source name is used to identify traces. It is used by a SourceFilter to determine whether a trace listener should produce the trace.

The following code example shows the use of the TraceSource constructor to create a new TraceSource object. This code example is part of a larger example provided for the TraceSource class.

// Initialize the trace source.
static TraceSource ts = new TraceSource("TraceTest");

Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.

.NET Framework

Supported in: 2.0

Community Additions