One of the features offered by .NET 2.0 is the use of the TraceSource class. In an attempt to demonstrate its use, I wanted to run my test under the following conditions:
1. Use TraceSource class (Not Trace or Debug classes)
2. Set up the trace solution in the application's
application.config file
3. Use Visual Basic.NET to test the trace
4. Test the TraceSource using Visual Studio.NET 2005 IDE "Windows application" rather than with a "Console application"
5. Use "Verbose" level
6. Direct all trace messages to the IDE's Output (Console Window)
7. I wanted to first test the traceSource solution using Visual Basic.NET before attempting it with C#.
---------------------
Config File Content:
Code:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.diagnostics>
<sources>
<source name="TestApp"
switchName="sourceSwitch"
switchType="System.Diagnostics.SourceSwitch">
<listeners>
<add name="console"
type="System.Diagnostics.ConsoleTraceListener">
</add>
<remove name="Default"/>
</listeners>
</source>
</sources>
<switches>
<add name="sourceSwitch" value="Verbose"/>
</switches>
</system.diagnostics>
</configuration>
Simple Source Code:
Code:
Imports System.Diagnostics
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
method1()
method2()
method3()
End Sub
Private Sub method1()
Console.WriteLine("Inside Method1")
End Sub
Private Sub method2()
Console.WriteLine("Inside Method2")
End Sub
Private Sub method3()
Console.WriteLine("Inside Method3")
End Sub
End Class
---------------------
At issue:
I Wanted to see autogenerated trace events identifying each method call in my application as they were being processed. I assume that Trace Level "Verbose " will show this, however,I do not see any trace statements in the Output window. I see the Console.Writeline statements that I've inserted, but I do not see anything generated by the TraceSource setup. Am I assuming too much from Tracesource? I believe that I was also suppose to add a #define TRACE preprocessor directive (for C#) at the beginning of my source code to turn Tracking on, however, I'm not sure how/where to do the same with Visual Basic.NET.
Thank you,
Mark