.NET 8.0 AOT DebugView

.NET 8.0 AOT DebugView

DebugView is an application that allows you to monitor debug output on your local system or on any computer on a network accessible via TCP/IP.

Last updated 8/29/2023 1:44 PM
JusterZhu
2 min read
Category
.NET
Topic
C# AOT
Tags
.NET C# AOT

1. Overview

During development, debugging and log output are unavoidable. Using the Trace object allows real-time tracking in both debug and release modes (when running the program with VS, DebugView cannot monitor it; just double-click the exe to run and monitor). Let's also test using the DebugView tool to view Trace.Write output debug information for applications published with AOT and in normal mode in .NET8.

2. DebugView

DebugView is an application that allows you to monitor debug output on your local system or on any computer on the network accessible via TCP/IP. It can display both kernel-mode and Win32 debug output, so you don't need a debugger to capture debug output generated by applications or device drivers, nor do you need to modify the application or driver to use non-standard debug output APIs.

It's very simple to use: start it as an administrator, then check these items in Options (when the .NET program we write runs, it will automatically capture the output message content).

3. Test Code

using System.Diagnostics;

namespace TraceAOT
{
   internal class Program
  {
       static void Main(string[] args)
      {
           // Specify the log file name for Trace output
           Trace.Listeners.Add(new TextWriterTraceListener("MyTraceListeners"));
           for (int i = 0; i < 10; i++)
          {
               Thread.Sleep(1000);
               // Output Trace information when the preceding expression is true. (Also adds info to Listeners.)
               Trace.WriteLineIf(i==5, "Trace message.");
          }
           // Flush to complete this output
           Trace.Flush();
           Console.WriteLine("OK");
           Console.Read();
      }
  }
}

4. Test Results

5. Conclusion

The DebugView tool works normally with .NET 8 applications, whether published with AOT or in normal mode. The Trace object allows real-time tracking in both debug and release modes, greatly simplifying our debugging and tracing process.

Keep Exploring

Related Reading

More Articles