我收到堆栈跟踪的错误...
System.ObjectDisposedException: Cannot access a disposed object.
Object name: 'Button'.
at System.Windows.Forms.Control.CreateHandle()
at System.Windows.Forms.Control.get_Handle()
at System.Windows.Forms.Control.PointToScreen(Point p)
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
产生此错误的代码是....
Friend Sub GoHome(ByVal sender As Form)
InTransit = True
sender.Close()
fMain.Show()
End Sub
当我只是切换 .show 和 .close 方法的顺序时它不会出错
Friend Sub GoHome(ByVal sender As Form)
InTransit = True
fMain.Show()
sender.Close()
End Sub
你能告诉我为什么在第一种情况下它会出错,为什么在第二种情况下没有?