Join 34,000+ subscribers and receive articles from our blog about software quality, testing, QA and security.



by logging a exception, the Data Property seems to store the Exception text.

Data is a memorystream object it seems, but can you please tell, what do you code in the first 3 bytes of that memory stream?

[code] Private Function FormatLogEntry(ByVal logEntry As Gurock.SmartInspect.LogEntry) As MailMessage
Dim _mm As New MailMessage
_mm.From = New MailAddress(_from)

    Dim _m As System.IO.MemoryStream = logEntry.Data

    If _to.Contains(";") Then
        For Each _adr As String In _to.Split(";")
    End If
    _mm.Subject = logEntry.Title
    _mm.Body = logEntry.Level
    _mm.Body += vbCrLf
    _mm.Body += System.Text.ASCIIEncoding.Default.GetString(_m.ToArray)

    Return _mm[/code]


Hello Wolfram,

Yes, the Data property is a MemoryStream. If you are dealing with an exception text, the stream content is an UTF-8 encoded string that contains the exception details such as the call stack. The first three bytes contain the UTF-8 BOM, so that the Console recognizes the data as an UTF-8 string.

You can easily convert the data to an Unicode string with the following method (example in C#):

[code]public static string StreamToString(Stream s)
if (s == null)
return String.Empty;

s.Position = 0;
TextReader r = new StreamReader(s);
return r.ReadToEnd();


Please let me know if this answers your question.