MessageBox and Form load

  • Thread starter Thread starter Jaydeep
  • Start date Start date
J

Jaydeep

Hi,
I am getting this error when I wrote MessageBox.Show("message") in my
Form_Load event.
'System.NullReferenceException' occurred in system.windows.forms.dll'
I am developing windows based C# application

My solution structure is like this.
1. Test Application(TestApp) Startup project
References MyComponent.dll
TestForm-->has--> ShowForm button-->onClick--> calls method ShowForm

2. Class Library Application(MyComponent.dll)
Form1 -->implements interface-->IMyInterface
IMyInterface-->exposes method-->ShowForm--has code-->this.Show()

So when I clicked on Show Form button on Test Application, I am getting the
above error...
Can anybody help me in this regard ?

TIA
Jaydeep
 
This may not be "the" answer, but I had the same exact problem when I wanted
a login dialog to appear when a certain form loads. I had to resort to the
dialog being called compeletely outside of the form. So it did from the menu
of the mdi parent window (the Assembly form is the form to be ultimately
opened):

Private Sub miAssemblyStart_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles miAssemblyStart.Click
Dim frm As New frmAssembly
Dim frm2 As New frmGrpLogOn
frm2.ShowDialog()
Select Case frm2.DialogResult

Case DialogResult.OK
With Me
frm.MdiParent = Me
frm.Show()
frm.tbProdTrkNo.Focus()
frm.Grp_ID = frm2.Grp_ID
frm.tbGrpName.Text = frm2.GrpName
frm.GrpLogInDT = frm2.GrpLogInDT
frm2.Close()
End With
Case DialogResult.Cancel
frm2.Close()
Exit Sub
End Select

End Sub
 
Back
Top