Who can explain this exception?

G

Guest

************** 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)
 
G

Guest

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top