XPToolbar Crasing and Red Cross coming.

Hi,

I have been using XPToolbar since some time but in the recent update i am getting issue with the component. Component gets crashed / a red cross appears within it.

i have tried my best to solve this, ensured that no cross thread communication should happen but still it is getting crashed randomly and some rarely too.



Is there anyway to handle these uncaught errors in the components? I am already using ThreadException and CurrentDomain.UnhandledException.


Stack Trace

07-Sep-2021 11:49:08.672 - Sender: System.Threading.Thread Class: System.Threading.Thread - Error: A generic error occurred in GDI+.

Stack: at System.Drawing.Image.FromHbitmap(IntPtr hbitmap, IntPtr hpalette)

   at System.Drawing.Image.FromHbitmap(IntPtr hbitmap)

   at System.Windows.Forms.ImageList.GetBitmap(Int32 index)

   at System.Windows.Forms.ImageList.ImageCollection.get_Item(Int32 index)

   at System.Windows.Forms.ImageList.ImageCollection.System.Collections.IList.get_Item(Int32 index)

   at Syncfusion.Windows.Forms.Tools.XPMenus.BarItemRenderer.DrawTextAndImage(Graphics g, RectangleF rectTextAndImage, Font textFont, Color textColor, Color bgColor, DrawItemState state)

   at Syncfusion.Windows.Forms.Tools.XPMenus.BarItemRenderer.DrawInterior(DrawToolbarItemEventArgs drawItemInfo)

   at Syncfusion.Windows.Forms.Tools.XPMenus.BarItemRenderer.OnPaint(Graphics g, Rectangle clippingRect)

   at Syncfusion.Windows.Forms.Tools.XPMenus.BarRenderer.OnPaint(Graphics g, Rectangle clipRect)

   at Syncfusion.Windows.Forms.Tools.XPMenus.MultilineBarRenderer.OnPaint(Graphics g, Rectangle clipRect)

   at Syncfusion.Windows.Forms.Tools.XPMenus.BarControlInternal.OnPaint(PaintEventArgs e)

   at Syncfusion.Windows.Forms.Tools.XPMenus.XPToolBar.OnPaint(PaintEventArgs e)

   at System.Windows.Forms.Control.PaintWithErrorHandling(PaintEventArgs e, Int16 layer)

   at System.Windows.Forms.Control.WmPaint(Message& m)

   at System.Windows.Forms.Control.WndProc(Message& m)

   at Syncfusion.Windows.Forms.Tools.XPMenus.BarControlInternal.WndProc(Message& m)

   at Syncfusion.Windows.Forms.Tools.XPMenus.XPToolBar.WndProc(Message& m)

   at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)

   at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)

   at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

Source: System.Drawing

####################################

Target Site: FromHbitmap




1 Reply

TB Thirupathi Bala Krishnan Syncfusion Team September 8, 2021 11:31 AM UTC

Hi Rakesh,

We have analyzed your reported query “Component gets crashed and red cross appears in XPToolBar”. However, we were unable to replicate the reported issue in our end. We noticed you described the sample crashing at randomly.
 
 
 
GDI+ throws an error when it cannot save file. Following are 2 reasons why this error occurs. 
  • When you are initializing a Bitmap object from an image stored on hard disk, it creates a lock on the underlying image file. Due to the lock when you try to save and overwrite your modified bitmap, it throws this error.
  • When you are saving a file, make sure the user has Write permission on the folder. This is important when you are getting this error on the Website because Website runs under restricted permissions
Could you please try the above solution and let me know the reported issue has been resolved or not. Otherwise share your working sample or modify attached sample as well as the replication procedures you took when you encountered the problem? Based on your updates, we’ll provide the solution at the earliest. 
Regards,
Thirupathi B.
 


Loader.
Up arrow icon