Problems Getting Trace Listeners Added via Application Configuration File - If you are having problems getting Trace Listeners added to your application via the configuration file, it could be because your reading incorrect MS documentation.
The LBTT Spot
"Lifeline is focused on developing and marketing systems designed to assist in the early detection of breast and ovarian cancer."



Problems Getting Trace Listeners Added via Application Configuration File

View C# Source Code

Article Categories:

.Net Framework
.Net Framework 1.1
ADO.NET
ASP.NET
Assemblies
Asynchronous Methods
C#
Collections
Configuration
Delegates
Events
Pocket PC
Regular Expressions
Smart Devices
SQL Server
Visual C#
Visual Studio .NET
Visual Studio .NET 2003
Windows Forms
XML

C# .Net Fun Menu

View Current Page's ASP.NET Source Code
C# Reference
C# Study Flash Cards
Valuable Links
Contact Us
Site Map
Mike's Portfolio

C# Reference Search:

Full Text Search:

Articles by Author:

Code Examples (zipped):

Problems Getting Trace Listeners Added via Application Configuration File

If you are having problems getting Trace Listeners added to your application via the configuration file, it could be because your reading incorrect MS documentation.
Category: .Net Framework, C#, Configuration, Posted 2/18/2004, By Mike G.

The .Net Framework SDK Documentation v1.0 contains incorrect information on how to add Trace Listeners to your application via the application configuration file (assemblyname.exe.config).

Specifically, the <listeners> Element page shows an example on how to add Trace Listeners, and the problem lies in the type attribute syntax.

.Net Framework SDK v1.0 - <listeners> Element Example: <configuration> <system.diagnostics> <trace autoflush="true" indentsize="0"> <listeners> <add name="MyListener" type="System.Diagnostics.TextWriterTraceListener,System" initializedata="MyListener.log"/> <add name="MyEventListener" type="System.Diagnostics.EventLogTraceListener,System" initializedata="MyConfigEventLog"/> </listeners> </trace> </system.diagnostics> </configuration>
.Net Framework SDK v.1.1 - <listeners> Element Example: <configuration> <system.diagnostics> <trace autoflush="true" indentsize="0"> <listeners> <add name="MyListener" type="System.Diagnostics.TextWriterTraceListener, Version, Culture, PublicKeyToken" initializedata="MyListener.log"/> <add name="MyEventListener" type="System.Diagnostics.EventLogTraceListener, Version, Culture, PublicKeyToken" initializedata="MyConfigEventLog"/> </listeners> </trace> </system.diagnostics> </configuration>
NOTE: Even though the second example is based on .Net Framework 1.1, it is still the correct syntax for applications built with .Net Framework 1.0 - it will work with both versions of the Framework.

type attribute syntax - you do not need to provide the assembly's version, culture or token. You can simply provide the type, so long as there's only one version, and it's not part of the GAC (Global Assembly Cache).