All pastes #402302 Raw Edit

Something

public text v1 · immutable
·published 2007-03-19 20:50 UTC
rendered paste body
Causes a NRE on the Console.WriteLine line, because OnLayout is getting called in the base constructor before MyControl's constructor gets a chance to run.


using System;
using System.Windows.Forms;
using System.Collections;

class TestForm : Form
{
	static void Main ()
	{
		Application.Run (new TestForm ());
	}

	public TestForm ()
	{
		MyControl mc = new MyControl ();
	}

	private class MyControl : ScrollableControl
	{
		private ArrayList al;
		
		public MyControl ()
		{
			al = new ArrayList ();
		}
		
		protected override void  OnLayout(LayoutEventArgs levent)
		{
			Console.WriteLine (al.Count);
 			base.OnLayout(levent);
		}
	}
}