diff --git a/src/Workspaces/Remote/ServiceHub/Shared/ServiceHubServiceBase.cs b/src/Workspaces/Remote/ServiceHub/Shared/ServiceHubServiceBase.cs index 8272c267c83f0d15d1aba405ee5a6d803f1db60c..23b71c88b9c1746a3248bd1f44d0c5fc844ef605 100644 --- a/src/Workspaces/Remote/ServiceHub/Shared/ServiceHubServiceBase.cs +++ b/src/Workspaces/Remote/ServiceHub/Shared/ServiceHubServiceBase.cs @@ -3,6 +3,7 @@ using System; using System.Diagnostics; using System.IO; +using System.Reflection; using System.Threading; using System.Threading.Tasks; using Microsoft.CodeAnalysis.Execution; @@ -254,11 +255,47 @@ private bool LogUnlessCanceled(Exception ex, CancellationToken cancellationToken { LogError("Exception: " + ex.ToString()); + LogExtraInformation(ex); + var callStack = new StackTrace().ToString(); LogError("From: " + callStack); } return false; } + + private void LogExtraInformation(Exception ex) + { + if (ex == null) + { + return; + } + + if (ex is ReflectionTypeLoadException reflection) + { + foreach (var loaderException in reflection.LoaderExceptions) + { + LogError("LoaderException: " + loaderException.ToString()); + LogExtraInformation(loaderException); + } + } + + if (ex is FileNotFoundException file) + { + LogError("FusionLog: " + file.FusionLog); + } + + if (ex is AggregateException agg) + { + foreach (var innerException in agg.InnerExceptions) + { + LogExtraInformation(innerException); + } + } + else + { + LogExtraInformation(ex.InnerException); + } + } } }