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