1

My understanding is that you need to register a listener to the trace output, but how would that even look like? Is there a trace stream associated with each execution of the application that Visual Studio/Rider listens to?

We can rephrase this question by asking:
How to write a simple console app that executes another application and listen to its trace output.

SpaceMonkey
  • 4,143
  • 5
  • 38
  • 60
  • https://referencesource.microsoft.com/#System/compmod/system/diagnostics/TraceInternal.cs,e19765f8de74589d Like the source code indicates, the information would be written to listeners, and https://referencesource.microsoft.com/#System/compmod/system/diagnostics/Trace.cs,30 shows where you should register yours. Visual Studio/Rider uses a debugger to hook to the applications they launch, so that they can manipulate things. I won't call that's "simple". But if you have enough permissions on the machine, you can modify `app.config` of that application to insert your listener. – Lex Li Oct 07 '18 at 00:25
  • @LexLi: No hooking, sending trace messages to a debugger is a standard OS API (`OutputDebugString`) that the .NET Debug and Trace classes use (with their default listener). – Ben Voigt Oct 07 '18 at 01:51
  • @BenVoigt Great to know that. Then it would be much easier to collect the output. – Lex Li Oct 07 '18 at 01:59

1 Answers1

1

To receive another application's debugging output, you need to attach to it as a debugger and call the WaitForDebugEvent function, looking for OUTPUT_DEBUG_STRING_INFO results (dwDebugEventCode == OUTPUT_DEBUG_STRING_EVENT)

If the other application is .NET, you potentially have some easier options, including configuring additional trace listeners in the app.config.

Ben Voigt
  • 277,958
  • 43
  • 419
  • 720