例外:无法访问已处置的对象。对象名称:文本框

时间:2014-11-18 17:08:00

标签: vb.net winforms exception

当我在Visual Studio中进行调试并且没有任何想法来修复它时,我遇到了这个异常。请帮忙。我在表单上使用了工具提示,这是我对原因的猜测。

我只是把它放在那里让它运行。只是发生例外。

Exceptions Details:
    System.ObjectDisposedException occurred
      HResult=-2146232798
      Message=Cannot access a disposed object.
    Object name: 'TextBox'.
      ObjectName=TextBox
      Source=System.Windows.Forms
      StackTrace:
           at System.Windows.Forms.Control.CreateHandle()
      InnerException: 

我觉得这篇文章也有同样的问题。 C# WinForms: ToolTip, cannot access to a disposed object

但我仍然不知道如何解决它。感谢。

修改

Dim frmFilterSelection As New FilterBoxSelection
  With frmFilterSelection
     .Owner = Me
     .ShowDialog()                              **HERE IS The Exception Location**
     If .DialogResult = Windows.Forms.DialogResult.OK Then
         If Not .SelectedFilter Is Nothing Then
            Dim newProjectItem As New cProjectItem
            ......

我等了2个小时才看到这个例外。重现它很难。

EDIT2: 点击“继续”后。外部Try Catch捕获了异常。异常信息详见:

System.ObjectDisposedException was caught
HResult=-2146232798
Message=Cannot access a disposed object.
Object name: 'TextBox'.
ObjectName=TextBox
Source=System.Windows.Forms
StackTrace:
   at System.Windows.Forms.Control.CreateHandle()
   at System.Windows.Forms.TextBoxBase.CreateHandle()
   at System.Windows.Forms.Control.get_Handle()
   at System.Windows.Forms.ToolTip.Hide(IWin32Window win)
   at System.Windows.Forms.ToolTip.TimerHandler(Object source, EventArgs args)
   at System.Windows.Forms.Timer.OnTick(EventArgs e)
   at System.Windows.Forms.Timer.TimerNativeWindow.WndProc(Message& m)
   at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
   at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& 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.RunDialog(Form form)
   at System.Windows.Forms.Form.ShowDialog(IWin32Window owner)
   at System.Windows.Forms.Form.ShowDialog()
   at Fansil.ProjectInfoForm.CreateNewFilterBox(String inType, Boolean isTransferedData) in C:\VAW-PROJECTS\Modified\SPS8-VS2012-2014-11-17 - TEST VERSION\Fansil 6.0\ProjectInfoForm.vb:line 15030
   at Fansil.ProjectInfoForm.cbnFBH_Click(Object sender, EventArgs e) in C:\VAW-PROJECTS\Modified\SPS8-VS2012-2014-11-17 - TEST VERSION\Fansil 6.0\ProjectInfoForm.vb:line 14785
   at System.Windows.Forms.ToolStripItem.RaiseEvent(Object key, EventArgs e)
   at System.Windows.Forms.ToolStripMenuItem.OnClick(EventArgs e)
   at System.Windows.Forms.ToolStripItem.HandleClick(EventArgs e)
   at System.Windows.Forms.ToolStripItem.HandleMouseUp(MouseEventArgs e)
   at System.Windows.Forms.ToolStripItem.FireEventInteractive(EventArgs e, ToolStripItemEventType met)
   at System.Windows.Forms.ToolStripItem.FireEvent(EventArgs e, ToolStripItemEventType met)
   at System.Windows.Forms.ToolStrip.OnMouseUp(MouseEventArgs mea)
   at System.Windows.Forms.ToolStripDropDown.OnMouseUp(MouseEventArgs mea)
   at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
   at System.Windows.Forms.Control.WndProc(Message& m)
   at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
   at System.Windows.Forms.ToolStrip.WndProc(Message& m)
   at System.Windows.Forms.ToolStripDropDown.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.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
   at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& 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.RunDialog(Form form)
   at System.Windows.Forms.Form.ShowDialog(IWin32Window owner)
   at System.Windows.Forms.Form.ShowDialog()
   at VAWPrice.frmStartUpInternal.frmStartUpInternal_Load(Object sender, EventArgs e) in C:\VAW-PROJECTS\Published\SPS8-VS2012-2014-11-17 - TEST VERSION\FansilMaintenance\frmStartUpInternal.vb:line 70
InnerException: 

0 个答案:

没有答案