1' 2' My = WindowsForms, with My.MyApplicationOnCreateForm creating an instance of WrongForm. 3' -main commandline arguments sets RightForm to the initial form. 4 5Option Strict On 6Option Explicit On 7 8Imports System 9Imports System.Reflection 10Imports System.Runtime.InteropServices 11 12Partial Class WrongForm 13 Inherits System.Windows.Forms.Form 14 15 Protected Overrides Sub OnLoad(ByVal e As EventArgs) 16 Environment.Exit(1) 17 End Sub 18End Class 19 20Partial Class RightForm 21 Inherits System.Windows.Forms.Form 22 23 Protected Overrides Sub OnLoad(ByVal e As EventArgs) 24 Environment.Exit(0) 25 End Sub 26End Class 27 28Namespace My 29 30 Partial Friend Class MyApplication 31 32 <Global.System.Diagnostics.DebuggerStepThroughAttribute()> _ 33 Public Sub New() 34 MyBase.New(Global.Microsoft.VisualBasic.ApplicationServices.AuthenticationMode.Windows) 35 Me.IsSingleInstance = False 36 Me.EnableVisualStyles = True 37 Me.SaveMySettingsOnExit = True 38 Me.ShutDownStyle = Global.Microsoft.VisualBasic.ApplicationServices.ShutdownMode.AfterMainFormCloses 39 End Sub 40 41 <Global.System.Diagnostics.DebuggerStepThroughAttribute()> _ 42 Protected Overrides Sub OnCreateMainForm() 43 Me.MainForm = Global.WindowsApplication1.WrongForm 44 End Sub 45 End Class 46End Namespace 47