FYI: GDI+ Crash in IDE

Submitted on: 2/18/2015 5:14:00 AM
By: LaVolpe (from psc cd)  
Level: Beginner
User Rating: By 3 Users
Compatibility: VB 5.0, VB 6.0
Views: 3922
     Generic thunk class added. Using it will negate crash described below and can be used to start GDI+... GDI+ when not shut down properly can crash IDE (maybe XP only. See comments below on test results). For those of you that use unsafe subclassing while in IDE, this effect is very familiar. Read the article below and to test a crash, you can run the zipped project. I, and others, can replicate the crash every time on XP Pro. May be a DLL version issue, may be something else.

This article has accompanying files
				GDI+ is an excellent tool for custom drawing and allowing VB to use PNGs, TIFFs, and other file formats. However, if it is not shut down, you can crash your app. XP-related and possibly Vista?

Uncompiled usercontrol (uc) problems.
1. Your uc creates GDI+ token for life of uc
2. In your uc's Terminate event, you shutdown GDI+
3. You run your app and hit END because of a Debug error or simply hit the VB toolbar's Stop button
4. A crash occurs shortly thereafter, maybe 2 minutes later, maybe 10 minutes later & you lost any updated/unsaved code you had.
This isn't a problem when uc is compiled because a compiled uc gets a terminate event even if it is added to an uncompiled project.
5. Why the crash? Because END prevents firing any uncompiled object's Terminate event and therefore, GDI+ isn't shut down because it gets triggered in the terminate event.

When in IDE:
To prevent GDI+ crashing. You have 2 choices
1. Create token, use GDI+, destroy token immediately
2. Never hit END or use VB's toolbar STOP button. And if you do. Save your project immediately. Close VB and re-open project.
Though a crash is probably imminent, at least you have some time to save your work

I experienced this recently with my AlphaImage control and troubleshooting led me to post this article.

winzip iconDownload article

Note: Due to the size or complexity of this submission, the author has submitted it as a .zip file to shorten your download time. Afterdownloading it, you will need a program like Winzip to decompress it.Virus note:All files are scanned once-a-day by Planet Source Code for viruses, but new viruses come out every day, so no prevention program can catch 100% of them. For your own safety, please:
  1. Re-scan downloaded files using your personal virus checker before using it.
  2. NEVER, EVER run compiled files (.exe's, .ocx's, .dll's etc.)--only run source code.
  3. Scan the source code with Minnow's Project Scanner

If you don't have a virus scanner, you can get one at many places on the net

Other 61 submission(s) by this author


Report Bad Submission
Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

Your Vote

What do you think of this article (in the Beginner category)?
(The article with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor (See voting log ...)

Other User Comments

 There are no comments on this submission.

Add Your Feedback
Your feedback will be posted below and an email sent to the author. Please remember that the author was kind enough to share this with you, so any criticisms must be stated politely, or they will be deleted. (For feedback not related to this particular article, please click here instead.)

To post feedback, first please login.