Completed
Last Updated: 18 Jul 2023 14:26 by ADMIN
Release R2 2023 SP1
Bjarke
Created on: 21 Jun 2023 05:42
Category: PdfViewer
Type: Bug Report
0
RadPdfViewer: ExternalException: A generic error occurred in GDI+ when using GetHicon

When creating many instances of RadPdfViewer:

        static void Main(string[] args)
        {
            int i = 1;
            try
            {
                Stopwatch stopwatch = Stopwatch.StartNew();
                while (true)
                {
                    using (RadPdfViewer pdfViewer = new RadPdfViewer())
                    {

                    }
                    Console.WriteLine($"iteration {i}, elapsed seconds: {stopwatch.Elapsed.TotalSeconds}");
                    i++;
                }
            }
            catch (Exception e)
            {
                Console.WriteLine($"Exception occurred at iteration {i}");
                Console.WriteLine(e);
                Console.ReadLine();
            }
        }

the following error occurs:  

System.Runtime.InteropServices.ExternalException (0x80004005): A generic error occurred in GDI+.
   at System.Drawing.Bitmap.GetHicon()
   at Telerik.WinControls.PdfViewer.MouseHandlers.PanHandler..ctor(MouseHandlersController controller, IFixedDocumentPresenter presenter)
   at Telerik.WinControls.PdfViewer.MouseHandlers.MouseHandlersController.BuildHandlers(IFixedDocumentPresenter presenter)
   at Telerik.WinControls.PdfViewer.MouseHandlers.MouseHandlersController..ctor(IFixedDocumentPresenter presenter)
   at Telerik.WinControls.UI.RadPdfViewerElement..ctor()
   at Telerik.WinControls.UI.RadPdfViewer.CreateViewerElement()
   at Telerik.WinControls.UI.RadPdfViewer.CreateChildItems(RadElement parent)
   at Telerik.WinControls.RadControl.Telerik.WinControls.IComponentTreeHandler.CreateChildItems(RadElement parent)
   at Telerik.WinControls.RadElementTree.InitializeRootElement()
   at Telerik.WinControls.RadControl.Construct()
   at Telerik.WinControls.RadControl..ctor()
   at Telerik.WinControls.UI.RadPdfViewer..ctor()
1 comment
ADMIN
Dess | Tech Support Engineer, Principal
Posted on: 21 Jun 2023 06:06

Hi, Bjarke,

Thank you for bringing this to our attention. We will do our best to introduce a proper fix in the upcoming release. Make sure that you follow this item in order to get notified once any status changes occur.

The possible solution that I can suggest is to use just a single instance of RadPdfViewer instead of creating so many instances. Thus, you can load a document, then print it. After that, you can load another document and so on. The following KB article is quite useful about the case for printing a pdf document without using the UI control:

https://docs.telerik.com/devtools/winforms/knowledge-base/pdfviewer-silent-print 

Please excuse us for the inconvenience caused.

Regards,
Dess | Tech Support Engineer, Principal
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.