locked
GdipCloneBitmapArea first chance exception - how to avoid? RRS feed

  • Question

  •  I stumbled into following problem - I  observed many First Chance Exceptions in my application 

    (f24.d00): Access violation - code c0000005 (first chance)
    First chance exceptions are reported before any exception handling.
    This exception may be expected and handled.
    eax=00308260 ebx=00000003 ecx=05e40002 edx=00308260 esi=08b56008 edi=00000003
    eip=4ed9b290 esp=0012d864 ebp=0012d88c iopl=0         nv up ei pl nz na po nc
    cs=001b  ss=0023  ds=0023  es=0023  fs=003b  gs=0000             efl=00210202
    gdiplus!GdipCloneBitmapArea+0x9da48:



    Code looks something like:

    images.Images.Add(new Bitmap(currentDirectory + "\\grid\\info.gif"));//7



    The question  is whether this is something I should be concerned and whether I can fix my code to avoid this exception  to happen - for example somehow pre-allocate buffers for images. 

    The problem is that I am chasing some Access Violations coming from different part of the application, so having clean code would make the process much easier.

    Thanks,
    corm11


    • Edited by corm11 Friday, August 29, 2008 11:28 AM better title
    Friday, August 29, 2008 11:26 AM

Answers

  • Don't worry about it.  Lots of code in the framework throws exceptions that get handled by the framework code itself.  In certain cases, it is cheaper to just trap the exception than to execute the code to avoid it.  It isn't very clean but there's nothing you can do about it.  But yeah, it's a pain if you try to filter out your own.
    Hans Passant.
    • Marked as answer by Zhi-Xin Ye Tuesday, September 2, 2008 11:07 AM
    Saturday, August 30, 2008 12:30 PM

All replies

  • Don't worry about it.  Lots of code in the framework throws exceptions that get handled by the framework code itself.  In certain cases, it is cheaper to just trap the exception than to execute the code to avoid it.  It isn't very clean but there's nothing you can do about it.  But yeah, it's a pain if you try to filter out your own.
    Hans Passant.
    • Marked as answer by Zhi-Xin Ye Tuesday, September 2, 2008 11:07 AM
    Saturday, August 30, 2008 12:30 PM
  • It's no doubt a bit late now, but I have had this same problem and the access violations only seem to occur with gif images. Replacing them with png's fixes it.
    Wednesday, April 15, 2009 9:50 AM