在 OnCreateMainForm() Sub 中的 Application.Designer.vb 中的错误

Jos*_*rin 4 windows-forms-designer vb.net-2010

我无法弄清楚这里的问题是什么。我从头开始项目,去调试,并收到错误:

System.InvalidOperationException 未处理 Message=创建表单时出错。有关详细信息,请参阅 Exception.InnerException。错误是:未将对象引用设置为对象的实例。

我不明白为什么在自动生成的文件中会发生此错误。这是完整的代码:

    '------------------------------------------------------------------------------
' <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
Run Code Online (Sandbox Code Playgroud)

错误发生在:

Me.MainForm = Global.AccountAndClientFull.frmMain

有什么建议?我无法弄清楚需要在项目属性的应用程序选项卡中进行哪些更改。

chr*_*may 5

我遇到了同样的错误并意识到这是因为我在表单代码中声明了一个私有默认构造函数。如果您创建了一个构造函数并且没有将其公开,请尝试将其公开。