Error in static void Main()

Cags

Contributor
Joined
Feb 19, 2004
Messages
695
Location
Melton Mowbray, England
An application which I have been working on recently started throwing up this error message whenever I try to debug it, has anyone got any idea what it means?

An unhandled exception of type 'System.OutOfMemoryException' occurred in system.windows.forms.dll

Additional information: Error creating window handle.

Stepping through the code shows the constructor of the form steps through correctly, but then it crashes out as soon as entering the Main() method.
 
I would have posted the code but I didn't know what to write as it was essentially a standard form with a single class added. I copied the class to another project along with the declaration and it works fine now. I still have no idea what caused the error which isn't ideal, but I'm not going to worrry about it unless it happens again.
 
Knowing almost nothing about your code, I would say that it might be possible that a logic error created an infinite loop which involved some kind of memory allocation. Kinda a stab in the dark.
 
Just out of interest I took a look at the old project and commented code out abit at a time to find out what was causing the error. I eventually tracked it down to a single line in the resize event of the form. I was setting

myForm.ClientSize = myControl.Size

this obviously caused a problem because when the constructor is ran myControl is null. It was basically an oversight, as the resize event should have been attached to the control not the form (hence making the form the right size to fit my control in). Copying my class to another project solved the problem as I was being less retarded at the time and actually attached the event to the right object.
 
Back
Top