Error: ArcGIS Engine Application crashes when ArcObjects makes calls to GDIplus
At version 10, COM-based applications using ArcGIS Engine Controls may abort with an unhandled exception error message dialog box displaying similar to the following message:
"Unhandled exception as 0x7x91b21a (ntdll.dll) in
violation writing location 0x00000010."
This crash may be caused by an ArcGIS component making use of GDI+ before GDI+ has been properly initialized. This problem is being investigated further by Esri. In the meantime, use one of the workarounds provided.
Solution or Workaround
There are two workarounds for this error.
It is necessary to call GdiplusStartup before creating any GDI+ objects, and it is necessary to delete all of the GDI+ objects (or have them go out of scope) before calling GdiplusShutdown. Add the following C++ code to the application:
To initialize the application, for example in the X() function:
Gdiplus::GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL);
Add the ToolbarControl to a dialog box, as this initiates GDI+.