A
Avi Elenko
When creating a WinForm control containing ~9600 (96K)
controls, a System.ComponentModel.Win32Exception with
NativeErrorCode set to 14 (0xE)
ERROR_OUTOFMEMORY "Not enough storage is available to
complete this operation" is thrown. Can please help how
one can bypass this limitation. I'm attaching sample c#
code that will recreate this problem. Please note that
once this exception is thrown, no new windows can be
created for this thread/form. In other words, the
MessageBox within catch statement will never show.
Thanks!
System.Windows.Forms.Panel mainPanel = new
System.Windows.Forms.Panel();
mainPanel.SuspendLayout();
try
{
for (int i=0; i<5000; ++i ) // Will break around 9700
(97K)
{
Panel p =new Panel(); p.Width =
this.ClientRectangle.Width; p.Height = 20; p.Top = i * 20;
p.Left = 0;
TextBox t = new TextBox();t.Text = ">>> Name= " +
i; t.Size = p.Size;
p.Controls.Add( t ); mainPanel.Controls.Add(
p );
}
}
catch ( System.Exception ex ){ MessageBox.Show( ex.ToString
() ); }
controls, a System.ComponentModel.Win32Exception with
NativeErrorCode set to 14 (0xE)
ERROR_OUTOFMEMORY "Not enough storage is available to
complete this operation" is thrown. Can please help how
one can bypass this limitation. I'm attaching sample c#
code that will recreate this problem. Please note that
once this exception is thrown, no new windows can be
created for this thread/form. In other words, the
MessageBox within catch statement will never show.
Thanks!
System.Windows.Forms.Panel mainPanel = new
System.Windows.Forms.Panel();
mainPanel.SuspendLayout();
try
{
for (int i=0; i<5000; ++i ) // Will break around 9700
(97K)
{
Panel p =new Panel(); p.Width =
this.ClientRectangle.Width; p.Height = 20; p.Top = i * 20;
p.Left = 0;
TextBox t = new TextBox();t.Text = ">>> Name= " +
i; t.Size = p.Size;
p.Controls.Add( t ); mainPanel.Controls.Add(
p );
}
}
catch ( System.Exception ex ){ MessageBox.Show( ex.ToString
() ); }