I am using
PDFSharp-MigraDoc-wpf 1.50.4000-beta3b with
ASP.NET MVC 5.2.2 to generate
one page PDFs on a Microsoft IIS 6.0 server which I then save to a MemoryStream.
This has been working flawlessly for many months, but in the last 10 days I've had 3785 exceptions across three different days (20th, 21st and then 27th). Almost all are of the type "
The operation completed successfully", but there are 9 cases of "
Not enough storage is available to process this command". In both cases the exception is:
Code:
System.ComponentModel.Win32Exception (0x80004005): The operation completed successfully
at MS.Win32.HwndWrapper..ctor(Int32 classStyle, Int32 style, Int32 exStyle, Int32 x, Int32 y, Int32 width, Int32 height, String name, IntPtr parent, HwndWrapperHook[] hooks)
at System.Windows.Media.MediaContextNotificationWindow..ctor(MediaContext ownerMediaContext)
at System.Windows.Media.MediaContext..ctor(Dispatcher dispatcher)
at System.Windows.Media.DrawingVisual.RenderOpen()
at PdfSharp.Drawing.XGraphics..ctor(DrawingContext dc, XSize size, XGraphicsUnit pageUnit, XPageDirection pageDirection)
at MigraDoc.Rendering.DocumentRenderer.PrepareDocument()
at MigraDoc.Rendering.PdfDocumentRenderer.PrepareDocumentRenderer(Boolean prepareCompletely)
at MigraDoc.Rendering.PdfDocumentRenderer.RenderDocument()
at SystemData.Order.GeneratePDF()
The code:
Code:
Document document = new Document();
PDFGenerator.CreatePDFPage(ref document, this, logoPath);
// Create a renderer
PdfDocumentRenderer pdfRenderer = new PdfDocumentRenderer();
// Associate the MigraDoc document with a renderer
pdfRenderer.Document = document;
// Layout and render document to PDF (debug timing shows only 27-56ms to render document)
pdfRenderer.RenderDocument();
MemoryStream ms = new MemoryStream();
pdfRenderer.PdfDocument.Save(ms, false);
ms.Seek(0, SeekOrigin.Begin);
In my googling I found a similar problem happening for MigraDoc with Azure back in July in this thread:
http://forum.pdfsharp.net/viewtopic.php?f=2&t=3405&p=10143&hilit=0x80004005#p10143Unfortunately, I'm not sure it is really relevant as it is a bit above my head, and so I would appreciate any help with what is going on.