I have created a form (frmSignIn) which asks for the log-in info and another (frmComposeMessage) which has all text boxes necessary for composing an email (to, subject, message body).
After clicking Sign In on the first form, it should hide it and open the second form, however I get this error:
System.InvalidOperationException was unhandled
Message=An error occurred creating the form. See Exception.InnerException for details. The error is: Object reference not set to an instance of an object.
Source=WindowsApplication1
StackTrace:
at WindowsApplication1.My.MyProject.MyForms.Create__Instance__[T](T Instance) in 17d14f5c-a337-4978-8281-53493378c1071.vb:line 190
at WindowsApplication1.My.MyProject.MyForms.get_frmComposeMessage()
at WindowsApplication1.frmSignIn.Button1_Click(Object sender, EventArgs e) in C:\Users\ETHAN\AppData\Local\Temporary Projects\WindowsApplication1\Form1.vb:line 5
at System.Windows.Forms.Control.onclick(EventArgs e)
at System.Windows.Forms.Button.onclick(EventArgs e)
at System.Windows.Forms.Button.onmouseup(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativewindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativewindow.WndProc(Message& m)
at System.Windows.Forms.Nativewindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun()
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel()
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(String[] commandLine)
at WindowsApplication1.My.MyApplication.Main(String[] Args) in 17d14f5c-a337-4978-8281-53493378c1071.vb:line 81
at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
InnerException: System.NullReferenceException
Message=Object reference not set to an instance of an object.
Source=WindowsApplication1
StackTrace:
at WindowsApplication1.frmComposeMessage..ctor() in C:\Users\NinjehKitteh\AppData\Local\Temporary Projects\WindowsApplication1\Form2.vb:line 7
InnerException:
But I don't know why. Here is the code of the first form:
Public Class frmSignIn
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSignIn.Click
If txtGmailAccount.Text <> Nothing And txtGmailPassword.Text <> Nothing Then
frmComposeMessage.Show()
Me.Hide()
Else
MessageBox.Show("Please complete all fields!", "Empty Fields", MessageBoxButtons.OK, MessageBoxIcon.Warning)
End If
End Sub
Private Sub frmSignIn_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
End Class
I tried creating a new object of openComposeMessage with
Dim openComposeMessage As New frmComposeMessage
But get told that I am referring to myself and should instead use 'Me.blahblah'
Can somebody help, please? I have re-made and coded the whole thing twice in hopes that it will solve it but have had no luck as of yet.
-Ninjeh.

New Topic/Question
Reply



MultiQuote





|