別の問題があります。Application.Designer.vb内で例外が処理されない
私は自分のVB.NETアプリケーションをビルドすることができます。しかし、私はそれをデバッグするために行くとき、私は未処理の例外を取得:
System.InvalidOperationException occurred HResult=0x80131509
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=ProovePC StackTrace:
at ProovePC.My.MyProject.MyForms.Create__Instance__[T](T Instance) in :line 190 at ProovePC.My.MyProject.MyForms.get_Front1() at ProovePC.My.MyApplication.OnCreateMainForm() in C:\Users\Phillip\source\Workspaces\Upwork Projects\ProoveIt\ProovePC\My Project\Application.Designer.vb:line 35 at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun() at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel() at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(String[] commandLine) at ProovePC.My.MyApplication.Main(String[] Args) in :line 81Inner Exception 1: NullReferenceException: Object reference not set to an instance of an object.
奇妙な部分は、それがApplication.Designer.vbファイルで、自動生成されたコードで発生することがあります。私は、コンストラクタが公開されていることと、フォームの名前は、このファイル内の名前と一致していることを確認している:
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 = true
Me.EnableVisualStyles = true
Me.SaveMySettingsOnExit = true
Me.ShutDownStyle = Global.Microsoft.VisualBasic.ApplicationServices.ShutdownMode.AfterAllFormsClose
End Sub
<Global.System.Diagnostics.DebuggerStepThroughAttribute()> _
Protected Overrides Sub OnCreateMainForm()
Me.MainForm = Global.ProovePC.Front1 'Error occurs here?
End Sub
End Class
End Namespace
私は新しいVB.NET居ないので、私はこれにはほとんど失われたが、私は考えてみたいです修正は単純なものであることを確認してください。私はVisual Studio 2017を実行しています。私はC#のバックグラウンドから来て、最近vb.netに入ったことに注意してください。だから、可能な限り説明してください。
編集:
形式コンストラクタ:
Public Sub New()
' This call is required by the designer.
'NewMethod()
InitializeComponents()
' Add any initialization after the InitializeComponent() call.
End Sub
編集:
[OK]をので、ここでは興味深い部分で、今私は、コンストラクタを生成し、自動内InitializeComponents機能自体にエラーを取得していますフォームの。この関数をコメントアウトすると、アプリケーションをビルドして実行することができます。私はそれまでにしか得られません。なぜなら、アプリケーションには、まだ接続していないハードウェアが完全に動作する必要があるからです。
さて、ここで興味深い部分は、私は、コンストラクタをコメントアウトした場合、未定義の参照エラー戻ってくるそれ以上のラインがあり、次のとおりです。不思議に思ったものについては
Public MainStatus As StatusStrip = StatusStrip1 'Error is here now
'Public Sub New()
' This call is required by the designer.
'InitializeComponent()
' Add any initialization after the InitializeComponent() call.
'End Sub
が、私は今で午前front1.vbファイル