Error during Debug of application - GDI+ is not properly initialized

Posted on 2004-07-30
Last Modified: 2008-01-09
I have a VB.Net client application.  When I run it in debug mode it works fine but when I go to exit the application to get out of debug and back to the development screen I get this error:

An unhandled exception of type 'System.Runtime.InteropServices.ExternalException' occurred in system.drawing.dll

Additional information: Internal error: GDI+ is not properly initialized.

I looked around the web and saw something that indicated that any file serialization "Close" calls needed to be removed.  This does not make sense to me since I do not have a file open during development.

Any help would be GREATLY appreciated,

Question by:HAMMER33333
  • 3
  • 3

Expert Comment

ID: 11677863
its not talking about closing a file, but closing an object.  can you post your code?

Author Comment

ID: 11679635
It is proprietary so I can't post the code.  Also it is a large amount of code.

However, you do put me onto a great idea.  I will check around at the objects.  What sort of object would this be?  A form, connection to a database, a webservice?

I am basically running the App in debug mode, clicking on the "x" in the upper right hand corner to close it down and I get this error.  If I click "Continue" when the error comes up it brings me back to my .Net developer solution screen.

Thanks for the help,


Expert Comment

ID: 11679828
this website makes a lot of sense of the situation

i think what you have is someone rendering a drawing surface.  

what could possibly happen is they have a handled exception at initialization (for instance if the .bmp file does not exist, dont initialize) then when the close call comes, the program never opened it, so it returns your error.

thats one possibility, it could be a few different reasons why youre getting your error.

is this professionally written software?  if so, id get a hold of the company.  if this is written by someone you know, get a hold of them and tell them to look into this error.

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).


Author Comment

ID: 11679877
I can show you the below code.  The program starts by running the module "ModuleDeclareForms".  The FfrmMain is created and displayed to the user in the "main" routine below.  I ran the debugger on this and when the user clicks the "x" in the upper right hand corner the code the code drops out of the "FfrmMain.ShowDialog()" goes to the "End Sub" and shortly after that the error appears.  Is there some other ending an application?

Thanks again,

Module ModuleDeclareForms

    Public FfrmMain As New frmMain()
    Public FfrmLogin As New frmLogin
    Public FfrmGetEmail As New frmGetEmail()
    Public FfrmAgentState As New frmAgentState()
    Public FfrmAbout As New frmAbout()
    Public FfrmClose As New frmClose
    Public FfrmSuspended As New frmSuspended()
    Public FfrmAgentProperties As New frmAgentProperties

    Sub main()


     End Sub

End Module

Author Comment

ID: 11694813

       How do you find something like that?   I have tried Try/Catch, looking for GDI instances, bad file names, and cannot find anything.  We are using the new Component One icons.  Could that have anything to do with it?

Thanks again,



Accepted Solution

bramsquad earned 200 total points
ID: 11787703
sorry this took me a while....

well your problem has nothing to do with the above code.  the error in question is in an event handler within the main form.  

ive never figured out why, but i know that combo boxes trigger the "SelectedIndexChanged" event before even the form_load event! -- you should try it, create a test app with a combo box and put msgbox("hello") in that event

where im going with this, is that on close there might be an event that gets activated somewhere....other than that, i really dont know what better direction to point you in.

best of luck, let me know if you have any more problems i can help with


Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

It’s quite interesting for me as I worked with Excel using for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Here's a very brief overview of the methods PRTG Network Monitor ( offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now