public static XmlSerializableException GetXmlSerializableException(Exception source) { XmlSerializableException exception = new XmlSerializableException(); exception.ErrorMesssage = source.Message; //trnaslate german words to english, to have the same HashCode for both variants StringBuilder sb = new StringBuilder(source.StackTrace); sb.Replace("bei ", "at "); sb.Replace(":Zeile ", ":line "); exception.StackTrace = sb.ToString(); foreach (DictionaryEntry dictionaryEntry in source.Data) { exception.AdditionalExceptionData.Add(new InfoItem(dictionaryEntry.Key.ToString(), dictionaryEntry.Value.ToString())); } if (source.InnerException != null) { exception.InnerExpcetion = GetXmlSerializableException(source.InnerException); } return exception; }
public void SetException(Exception exception) { XmlSerializableException serializableException = XmlSerializableException.GetXmlSerializableException(exception); XmlSerializableException lastException = serializableException; while (lastException.InnerExpcetion != null) { lastException = lastException.InnerExpcetion; } XmlSerializableException innerException = new XmlSerializableException(); innerException.ErrorMesssage = "This exception is manually added only to print the current stack trace of the client."; try { innerException.StackTrace = new StackTrace(true).ToString(); } catch { } lastException.InnerExpcetion = innerException; this.exception = serializableException; }