Search code examples
vb.net-2010windows-forms-designer

Error inside of Application.Designer.vb inside of OnCreateMainForm() Sub


I can't figure out what the issue is here. I started project from scratch, went to debug, and received 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.

I am not understand why this error is occurring in an auto-generated file. Here is the code in it's entirety:

    '------------------------------------------------------------------------------
' <auto-generated>
'     This code was generated by a tool.
'     Runtime Version:4.0.30319.269
'
'     Changes to this file may cause incorrect behavior and will be lost if
'     the code is regenerated.
' </auto-generated>
'------------------------------------------------------------------------------

Option Strict On
Option Explicit On


Namespace My

    'NOTE: This file is auto-generated; do not modify it directly.  To make changes,
    ' or if you encounter build errors in this file, go to the Project Designer
    ' (go to Project Properties or double-click the My Project node in
    ' Solution Explorer), and make changes on the Application tab.
    '
    Partial Friend Class MyApplication

        <Global.System.Diagnostics.DebuggerStepThroughAttribute()>  _
        Public Sub New()
            MyBase.New(Global.Microsoft.VisualBasic.ApplicationServices.AuthenticationMode.Windows)
            Me.IsSingleInstance = false
            Me.EnableVisualStyles = true
            Me.SaveMySettingsOnExit = true
            Me.ShutDownStyle = Global.Microsoft.VisualBasic.ApplicationServices.ShutdownMode.AfterMainFormCloses
        End Sub

        <Global.System.Diagnostics.DebuggerStepThroughAttribute()>  _
        Protected Overrides Sub OnCreateMainForm()
            Me.MainForm = Global.AccountAndClientFull.frmMain 'HERE IS WHERE THE ERROR OCCURS
        End Sub
    End Class
End Namespace

Error occurs at:

Me.MainForm = Global.AccountAndClientFull.frmMain

Any suggestions? I can't figure out what changes need to be made in the application tab of the project properties.


Solution

  • Make sure you have a Form Class called frmMain, attention not the file name but the Class Name.

    Maybe you have renamed the Form file name to frmMain.vb but in the code of the file the signature of the class remains different.