title: Getting ObjectDisposed exception after closing form
body: <p>Mainform:</p>
  
  <pre><code>Sub Button3Click(sender As Object, e As EventArgs)
          Form1.show()
          MsgBox("back")
      End Sub
  </code></pre>
  
  <p>This open a new form Form1 on button click</p>
  
  <p>Form1:</p>
  
  <pre><code>Public Partial Class Form1
      Public Sub New()
          ' The Me.InitializeComponent call is required for Windows Forms designer support.
          Me.InitializeComponent()
          Dim filePath As String
          filePath = System.IO.Path.Combine(MainForm.folderpath,"logininfo.cfg")
          Dim adptrname As String
          adptrname=MainForm.adptername.Trim
          MsgBox(adptrname.Length)
          Dim args As String
  
          args="netsh int ipv4 set address name=""" &amp; adptrname &amp; """ source=dhcp"
          Dim proc As New System.Diagnostics.Process()        
          proc.StartInfo.FileName = "netsh"
          proc.StartInfo.Verb="RunAs"
          proc.StartInfo.CreateNoWindow = true
          proc.StartInfo.RedirectStandardOutput = True
          proc.StartInfo.RedirectStandardError = True 
          proc.StartInfo.Arguments = args
          proc.StartInfo.UseShellExecute = False
          proc.Start()
  
  
          My.Computer.FileSystem.WriteAllText(MainForm.filePath, proc.StandardOutput.ReadToEnd(), True)
          My.Computer.FileSystem.WriteAllText(MainForm.filePath, proc.StandardError.ReadToEnd(), True)
  
  
          proc.WaitForExit()
  
          MsgBox(args)
  
          MsgBox(adptrname)
          Me.Close
  
      End Sub
  End Class
  </code></pre>
  
  <p>After all the above code runs I get the ObjectDisposed Exception at the Form1.show() line in mainform I cannot understand which disposed object is being called here.</p>
  
  <pre><code>System.ObjectDisposedException: Cannot access a disposed object.
     at System.Windows.Forms.Control.CreateHandle()
     at System.Windows.Forms.Form.CreateHandle()
     at System.Windows.Forms.Control.get_Handle()
     at System.Windows.Forms.Control.SetVisibleCore(Boolean value)
     at System.Windows.Forms.Form.SetVisibleCore(Boolean value)
     at System.Windows.Forms.Control.Show()
     at SIBMConnect.MainForm.Button3Click(Object sender, EventArgs e) in C:\Users\JONAH\Documents\SharpDevelop Projects\SIBMConnect\SIBMConnect\MainForm.vb:line 92
     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&amp; m, MouseButtons button, Int32 clicks)
     at System.Windows.Forms.Control.WndProc(Message&amp; m)
     at System.Windows.Forms.ButtonBase.WndProc(Message&amp; m)
     at System.Windows.Forms.Button.WndProc(Message&amp; m)
     at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message&amp; m)
     at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message&amp; m)
     at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
     at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG&amp; 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 System.Windows.Forms.Application.Run(ApplicationContext context)
     at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun()
     at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel()
     at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(String[] commandLine)
     at SIBMConnect.My.MyApplication.Main(String[] Args) in 17d14f5c-a337-4978-8281-53493378c1071.vb:line 81
  </code></pre>
  
  <p>Please help</p>