Pour n'imprimer que la Messagepartie des exceptions profondes, vous pouvez faire quelque chose comme ceci:
public static string ToFormattedString(this Exception exception)
{
    IEnumerable<string> messages = exception
        .GetAllExceptions()
        .Where(e => !String.IsNullOrWhiteSpace(e.Message))
        .Select(e => e.Message.Trim());
    string flattened = String.Join(Environment.NewLine, messages); // <-- the separator here
    return flattened;
}
public static IEnumerable<Exception> GetAllExceptions(this Exception exception)
{
    yield return exception;
    if (exception is AggregateException aggrEx)
    {
        foreach (Exception innerEx in aggrEx.InnerExceptions.SelectMany(e => e.GetAllExceptions()))
        {
            yield return innerEx;
        }
    }
    else if (exception.InnerException != null)
    {
        foreach (Exception innerEx in exception.InnerException.GetAllExceptions())
        {
            yield return innerEx;
        }
    }
}
Cela parcourt de manière récursive toutes les exceptions internes (y compris le cas de AggregateExceptions) pour afficher toutes les Messagepropriétés qu'elles contiennent, délimitées par un saut de ligne.
Par exemple 
var outerAggrEx = new AggregateException(
    "Outer aggr ex occurred.",
    new AggregateException("Inner aggr ex.", new FormatException("Number isn't in correct format.")),
    new IOException("Unauthorized file access.", new SecurityException("Not administrator.")));
Console.WriteLine(outerAggrEx.ToFormattedString());
  Un agrex externe s'est produit. 
  Intérieur aggr ex. 
  Le nombre n'est pas au format correct. 
  Accès aux fichiers non autorisé. 
  Pas administrateur.
Vous devrez écouter les autres propriétés d' exception pour plus de détails. Par exemple Dataaura quelques informations. Vous pourriez faire:
foreach (DictionaryEntry kvp in exception.Data)
Pour obtenir toutes les propriétés dérivées (pas sur la Exceptionclasse de base ), vous pouvez faire:
exception
    .GetType()
    .GetProperties()
    .Where(p => p.CanRead)
    .Where(p => p.GetMethod.GetBaseDefinition().DeclaringType != typeof(Exception));