PDFsharp & MigraDoc Foundation
https://forum.pdfsharp.net/

Appearance of MigraDoc-wpf exceptions on IIS server
https://forum.pdfsharp.net/viewtopic.php?f=2&t=3440
Page 1 of 1

Author:  Tarostar [ Tue Aug 30, 2016 12:35 pm ]
Post subject:  Appearance of MigraDoc-wpf exceptions on IIS server

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#p10143

Unfortunately, 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.

Author:  TH-Soft [ Tue Aug 30, 2016 1:31 pm ]
Post subject:  Re: Appearance of MigraDoc-wpf exceptions on IIS server

Hi!

I think it is the same issue, so I would try the code modification from the other thread.

And please provide feedback whether the code modification solves your problem.

Page 1 of 1 All times are UTC
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/