public MemoryStream ExportDocument() { try { WmlDocument doc = DocumentBuilder.BuildDocument(sources); MemoryStream stream = new MemoryStream(); doc.WriteByteArray(stream); BuildCustomProperties(stream); return(stream); } catch (Exception ex) { Logger.Fatal(ex, "An error occurred while exporting document."); throw ex; } }