Everything about my daily life as a programmer/Electrical Engineer!

Silverlight WCF Inner-Exceptions

Found a quick and dirty way to do WCF exceptions in silverlight http://code.msdn.microsoft.com/Project/Download/FileDownload.aspx?ProjectName=silverlightws&DownloadId=3473 .  The problem is that it doesn’t do inner-exceptions.

I changed the raw fault exception around a bit to get inner exceptions working.

 

    public static RawFaultException BuildRawFaultException(XmlDictionaryReader reader)
{
List<string> messages = new List<string>();
List<string> stacktraces = new List<string>();
while (reader.ReadToFollowing("Message"))
{
string message = reader.ReadElementContentAsString();
string stackTrace = reader.ReadElementContentAsString("StackTrace", reader.NamespaceURI);
messages.Add(message);
stacktraces.Add(stackTrace);
}
RawFaultException e = null;
for (int i = 0; i < messages.Count; i++)
{
if (e == null) { e = new RawFaultException(messages[i]) { stackTrace = stacktraces[i] }; }
else { e = new RawFaultException(messages[i], e) { stackTrace = stacktraces[i] }; }
}

return e;

}
}

No comments: