Adding a view to a layout control

Topics: CAB & Smart Client Software Factory
Jul 6, 2006 at 7:25 AM
originally posted by: TimLarsonEP

I am using the latest version of the SCSF I have created a view and I am trying to add it to the layout control and any time I try to drop it on the layout control I am getting and error:

Failed to create control "Test2'. The error message follows:
'System.NullReferenceException: Object reference not set to an instance of an object at TestApp.Reports.Test2.OnLoad(EventArgs e) in ....Test2\Test2.cs:Line 50
at System.WindowsForms.UserControl.OnCreateControl()

This is what is on line 50:


I have not added any thing extra to the control it is just the base generated by the view with presenter generator.

Jul 6, 2006 at 8:59 AM
originally posted by: TimLarsonEP

I put a try catch around the statement in question and it lets me drop the view on the layout now and everything appears to work fine.

Jul 6, 2006 at 8:30 PM
originally posted by: DapinderSingh

Try adding the code below in the onLoad event of the control which you want to drop on a view

protected override void OnLoad(EventArgs e)
if (this.DesignMode == false)
//all the required code

This may solve your problem. Try this after removing try - catch statement.