Microsoft.diagnosticshub.diagnostics.collectionstartfailedhubexception

await diagnosticHubSession.StartCollectionAsync(targetProcessId);

If the target process requires elevation, launch Visual Studio with admin rights ( Right-click → Run as administrator ).

In Visual Studio: Debug → Options → Enable Diagnostic Tools while debugging (uncheck). If the problem disappears, a specific tool (e.g., CPU Usage) is misconfigured. 7. Code Example (Illustrative) You would not typically catch this exception in production code. However, a diagnostic extension or custom profiler host might handle it like this: await diagnosticHubSession

Common failure scenarios include:

catch (DiagnosticsCollectionStartFailedHubException ex) This restores missing or corrupted Diagnostic Hub components

From the Visual Studio Installer → select More → Repair . This restores missing or corrupted Diagnostic Hub components.

Console.WriteLine($"Diagnostic collection failed: ex.Message"); if (ex.InnerException is UnauthorizedAccessException) Console.WriteLine("Try running Visual Studio as Administrator."); // Log to telemetry or retry with fallback configuration If the target process requires elevation

Delete temporary diagnostic files: %TEMP%\Microsoft Diagnostics Hub\ %LOCALAPPDATA%\Microsoft\VisualStudio\<version>\DiagnosticsHub\

microsoft.diagnosticshub.diagnostics.collectionstartfailedhubexception