/// <summary> Is invoked when <see cref="IExceptionDialog.Exception"/> has been changed. </summary> /// <param name="value">New value</param> private void OnExceptionChanged(Exception value) { if (value == null) { return; } ((IExceptionDialog)this).Text = value.Message; List <ExceptionInfo> exceptionStack = new List <ExceptionInfo>(5); exceptionStack.Add(ExceptionInfo.From(value)); Exception innerException = value.InnerException; while (innerException != null) { exceptionStack.Add(ExceptionInfo.From(innerException)); innerException = innerException.InnerException; } IEnumerable <string> messages = exceptionStack.Select(ex => ex.Message); string aggregatedMessage = string.Join(Environment.NewLine, messages); IEnumerable <string> stacktrace = exceptionStack.Select(ex => ex.Stacktrace); string aggregatedStacktrace = string.Join(Environment.NewLine, stacktrace); ExceptionInfo allMessageInfo = new ExceptionInfo("All messages", aggregatedMessage, aggregatedStacktrace, value.TargetSite.Name, value.Source); exceptionStack.Insert(0, allMessageInfo); _detailsListBox.DataSource = exceptionStack; _detailsListBox.DisplayMember = "Type"; _detailsListBox.SelectedValueChanged += (sender, args) => { ExceptionInfo exInfo = (ExceptionInfo)((ListBox)sender).SelectedItem; string rtfText = exInfo.ToRtfString(); _detailsTextBox.Rtf = rtfText; }; _detailsListBox.SelectionMode = SelectionMode.One; _detailsListBox.SelectedItem = exceptionStack[0]; }