With the sharpPDF library I generate a pdf memory stream, and I want to send it directly via email. But the line ms.Seek(.... gives an ObjectDisposedExcepti
One simple approach is to get the byte array out of the closed MemoryStream and create another one:
pdf.CreatePDF(ms)
ms = new MemoryStream(ms.ToArray())
Dim email As New EmailService
email.Send(ms)
Note that it's fine to call MemoryStream.ToArray on a closed / disposed instance of MemoryStream
. It's even documented:
Note
This method works when the MemoryStream is closed.