Home All Groups Group Topic Archive Search About

Who can explain this exception?

Author
21 Dec 2005 12:27 AM
Chester
************** Exception Text **************
System.ComponentModel.Win32Exception: Not enough storage is available to
process this command
   at System.Windows.Forms.Form.UpdateLayered()
   at System.Windows.Forms.Form.OnHandleCreated(EventArgs e)
   at System.Windows.Forms.Control.WmCreate(Message& m)
   at System.Windows.Forms.Control.WndProc(Message& m)
   at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
   at System.Windows.Forms.ContainerControl.WndProc(Message& m)
   at System.Windows.Forms.Form.WmCreate(Message& m)
   at System.Windows.Forms.Form.WndProc(Message& m)
   at System.Windows.Forms.ControlNativeWindow.OnMessage(Message& m)
   at System.Windows.Forms.ControlNativeWindow.WndProc(Message& m)
   at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg,
IntPtr wparam, IntPtr lparam)

Author
21 Dec 2005 9:20 PM
Chester
So no one answer me. But I solved my problem(another guy's code). Look at the
following code

f1 as Form = New Form
f2 as Form = New Form
f2.Owner = f1
f2 = Nothing

It looks like that the instance referenced by f2 will be garbage collected.
But actually it doesn't. Why? Because the instance is owned by f1, there is
still a reference to this form instance. When we loop over the code
indefinitely, all memory is eaten up. then the following exception is thrown.

f2.Owner = f1 is deceiptive. Actually it is f1.OwnedForm.Add(f2).

Chester

Show quote
"Chester" wrote:

> ************** Exception Text **************
> System.ComponentModel.Win32Exception: Not enough storage is available to
> process this command
>    at System.Windows.Forms.Form.UpdateLayered()
>    at System.Windows.Forms.Form.OnHandleCreated(EventArgs e)
>    at System.Windows.Forms.Control.WmCreate(Message& m)
>    at System.Windows.Forms.Control.WndProc(Message& m)
>    at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
>    at System.Windows.Forms.ContainerControl.WndProc(Message& m)
>    at System.Windows.Forms.Form.WmCreate(Message& m)
>    at System.Windows.Forms.Form.WndProc(Message& m)
>    at System.Windows.Forms.ControlNativeWindow.OnMessage(Message& m)
>    at System.Windows.Forms.ControlNativeWindow.WndProc(Message& m)
>    at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg,
> IntPtr wparam, IntPtr lparam)
>
>

AddThis Social Bookmark Button