PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Fri Dec 02, 2022 9:17 am

All times are UTC

Forum rules

Please read this before posting on this forum: Forum Rules

Post new topic Reply to topic  [ 2 posts ] 
Author Message
PostPosted: Fri Dec 18, 2020 6:23 pm 

Joined: Fri Dec 18, 2020 5:56 pm
Posts: 1
Please, can somebody help how to fix the error :
System.ComponentModel.Win32Exception (0x80004005): The operation completed successfully at ...

The error happens in the following code sometimes inside PDF library.

private static void AddPageToPdfDoc(PdfDocument doc, FormattedDocumentPage contentPage, bool addWatermark, Func<Stream> getWatermarkStream, bool printWatermark)
var docPage = doc.AddPage();
docPage.Width = XUnit.FromMillimeter(contentPage.PageMillimetersWidth);
docPage.Height = XUnit.FromMillimeter(contentPage.PageMillimetersHeight);

// Exception on this line happens
using (var graphics = XGraphics.FromPdfPage(docPage))

It looks due the exception below that some Win32 api error hapens because of memory leaks.

Exception itself:

System.ComponentModel.Win32Exception (0x80004005): The operation completed successfully at MS.Win32.UnsafeNativeMethods.RegisterClassEx(WNDCLASSEX_D wc_d) 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.Threading.Dispatcher..ctor() at System.Windows.Threading.Dispatcher.get_CurrentDispatcher() at PdfSharp.Drawing.XGraphics..ctor(PdfPage page, XGraphicsPdfPageOptions options, XGraphicsUnit pageUnit, XPageDirection pageDirection) at Siberia.Services.PrintDocuments.PdfGenerator.AddPageToPdfDoc(PdfDocument doc, FormattedDocumentPage contentPage, Boolean addWatermark, Func1 getWatermarkStream, Boolean printWatermark) in D:\a\1\s\Sources\Web\Siberia.Services\PrintDocuments\PdfGenerator.cs:line 93 at Siberia.Services.PrintDocuments.PdfGenerator.AddPageToPdfDoc(PdfDocument doc, FormattedDocumentPage contentPage, String watermarkName, Boolean printWatermark) in D:\a\1\s\Sources\Web\Siberia.Services\PrintDocuments\PdfGenerator.cs:line 69 at Siberia.Services.PrintDocuments.PdfGenerator.CreatePdfDocument(DocumentPageWithWatermark[] pages) in D:\a\1\s\Sources\Web\Siberia.Services\PrintDocuments\PdfGenerator.cs:line 31 at Siberia.Services.WorkCapacityCertificate.CertificateOfCapacityService.CompleteCertificateOfCapacity(DbContext context, Int32 practiceId, Int32 certificateOfCapacityId) in D:\a\1\s\Sources\Web\Siberia.Services\WorkCapacityCertificate\CertificateOfCapacityService.cs:line 367 at Siberia.Services.WorkCapacityCertificate.CertificateOfCapacityService.UpdateCertificateOfCapacity(Int32 practiceId, CertificateOfCapacity certificateOfCapacity) in D:\a\1\s\Sources\Web\Siberia.Services\WorkCapacityCertificate\CertificateOfCapacityService.cs:line 282 at Siberia.Controllers.BaseController.ExecuteWithValidation[TModel](TModel model, String modelPrefix, Action1 serviceAction, Func1 successResult, Func1 failedResult) in D:\a\1\s\Sources\Web\Siberia.Controllers\BaseController.cs:line 368

Reply with quote  
PostPosted: Mon Dec 21, 2020 8:28 am 
PDFsharp Expert
User avatar

Joined: Sat Mar 14, 2015 10:15 am
Posts: 747
Location: CCAA
Do you use the latest WPF build of PDFsharp/MigraDoc 1.51?

See also:


Best regards
(Freelance Software Developer with several years of MigraDoc/PDFsharp experience)

Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC

Who is online

Users browsing this forum: No registered users and 16 guests

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Privacy Policy, Data Protection Declaration, Impressum
Powered by phpBB® Forum Software © phpBB Group