Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
swdev:dotnet:debugging [2011/03/25 10:02] smayr [Writing Events] |
swdev:dotnet:debugging [2011/08/30 16:34] (current) smayr [Debugging] |
||
---|---|---|---|
Line 1: | Line 1: | ||
== Debugging == | == Debugging == | ||
+ | |||
+ | * Enable WPF debug output. In Visual Studio, Options > Debugging > Output Window > WPF Trace Settings > Data Binding > All. | ||
+ | * Add a high TraceLevel to your binding: <code csharp> | ||
+ | * Run application, | ||
+ | * Add '' | ||
+ | * [[swdev: | ||
+ | * [[http:// | ||
+ | * [[http:// | ||
+ | * [[http:// | ||
+ | * [[http:// | ||
+ | * [[http:// | ||
+ | * [[http:// | ||
== Using System.Diagnostics == | == Using System.Diagnostics == | ||
Line 64: | Line 76: | ||
Alternatively, | Alternatively, | ||
<code csharp> | <code csharp> | ||
- | TraceSource srcMyApp = new TraceSource(" | + | TraceSource srcMyApp = new TraceSource(" |
srcMyApp.TraceInformation(" | srcMyApp.TraceInformation(" | ||
srcMyApp.TraceEvent(TraceEventType.Error, | srcMyApp.TraceEvent(TraceEventType.Error, | ||
Line 103: | Line 115: | ||
elog.EnableRaisingEvents = true; | elog.EnableRaisingEvents = true; | ||
elog.WriteEntry(message); | elog.WriteEntry(message); | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | Another example (by Microsoft): | ||
+ | <code csharp> | ||
+ | using System; | ||
+ | using System.Diagnostics; | ||
+ | using System.Threading; | ||
+ | |||
+ | class MySample{ | ||
+ | |||
+ | public static void Main(){ | ||
+ | |||
+ | // Create the source, if it does not already exist. | ||
+ | if(!EventLog.SourceExists(" | ||
+ | { | ||
+ | //An event log source should not be created and immediately used. | ||
+ | // | ||
+ | // | ||
+ | // | ||
+ | EventLog.CreateEventSource(" | ||
+ | Console.WriteLine(" | ||
+ | Console.WriteLine(" | ||
+ | // The source is created. | ||
+ | return; | ||
+ | } | ||
+ | |||
+ | // Create an EventLog instance and assign its source. | ||
+ | EventLog myLog = new EventLog(); | ||
+ | myLog.Source = " | ||
+ | |||
+ | // Write an informational entry to the event log. | ||
+ | myLog.WriteEntry(" | ||
+ | |||
+ | } | ||
} | } | ||
</ | </ |