PDFsharp & MigraDoc Foundation
http://forum.pdfsharp.com/

Pdf Win32Exception The operation completed successfully
http://forum.pdfsharp.com/viewtopic.php?f=2&t=4210
Page 1 of 1

Author:  RomanMoroz [ Fri Dec 18, 2020 6:23 pm ]
Post subject:  Pdf Win32Exception The operation completed successfully

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

Author:  TH-Soft [ Mon Dec 21, 2020 8:28 am ]
Post subject:  Re: Pdf Win32Exception The operation completed successfully

Do you use the latest WPF build of PDFsharp/MigraDoc 1.51?

See also:
viewtopic.php?f=2&t=832

search.php?keywords=0x80004005&terms=all&author=&sc=1&sf=all&sk=t&sd=d&sr=posts&st=0&ch=300&t=0&submit=Search

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