从另一个object
处理form
的{{1}}时exception
就像Parameter is not valid
访问第二种表单的代码
Assembly X = Assembly.LoadFile(Application.StartupPath + "\\Test.dll");
Form frminv = (Form)X.CreateInstance("Test.Form1");
frminv.Dispose();
这是表单处理方法(来自Designer.cs)
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);// exception is thrown from here
}
这是堆栈跟踪
at System.Drawing.Image.get_FrameDimensionsList()
at System.Drawing.ImageAnimator.CanAnimate(Image image)
at System.Drawing.ImageAnimator.ImageInfo..ctor(Image image)
at System.Drawing.ImageAnimator.Animate(Image image, EventHandler onFrameChangedHandler)
at System.Windows.Forms.PictureBox.Animate(Boolean animate)
at System.Windows.Forms.PictureBox.Animate()
at System.Windows.Forms.PictureBox.OnVisibleChanged(EventArgs e)
at System.Windows.Forms.Control.OnParentVisibleChanged(EventArgs e)
at System.Windows.Forms.Control.OnVisibleChanged(EventArgs e)
at System.Windows.Forms.Control.OnParentVisibleChanged(EventArgs e)
at System.Windows.Forms.Control.OnVisibleChanged(EventArgs e)
at System.Windows.Forms.ScrollableControl.OnVisibleChanged(EventArgs e)
at System.Windows.Forms.Control.OnParentVisibleChanged(EventArgs e)
at System.Windows.Forms.Control.OnVisibleChanged(EventArgs e)
at System.Windows.Forms.ScrollableControl.OnVisibleChanged(EventArgs e)
at System.Windows.Forms.Control.OnParentVisibleChanged(EventArgs e)
at System.Windows.Forms.Control.OnVisibleChanged(EventArgs e)
at System.Windows.Forms.ScrollableControl.OnVisibleChanged(EventArgs e)
at System.Windows.Forms.Form.OnVisibleChanged(EventArgs e)
at System.Windows.Forms.Control.WmShowWindow(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
at System.Windows.Forms.ContainerControl.WndProc(Message& m)
at System.Windows.Forms.Form.WmShowWindow(Message& m)
at System.Windows.Forms.Form.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.IntDestroyWindow(HandleRef hWnd)
at System.Windows.Forms.UnsafeNativeMethods.DestroyWindow(HandleRef hWnd)
at System.Windows.Forms.NativeWindow.DestroyHandle()
at System.Windows.Forms.Control.DestroyHandle()
at System.Windows.Forms.Control.Dispose(Boolean disposing)
at System.Windows.Forms.ContainerControl.Dispose(Boolean disposing)
at System.Windows.Forms.Form.Dispose(Boolean disposing)
at ICFTWaveForm.WaveForm.Dispose(Boolean disposing)
at System.ComponentModel.Component.Dispose()
at System.Windows.Forms.Control.Dispose(Boolean disposing)
at System.ComponentModel.Component.Dispose()
at System.Windows.Forms.Control.Dispose(Boolean disposing)
at System.ComponentModel.Component.Dispose()
at System.Windows.Forms.Control.Dispose(Boolean disposing)
at System.Windows.Forms.ContainerControl.Dispose(Boolean disposing)
at System.Windows.Forms.Form.Dispose(Boolean disposing)
at XXXX.frmMain.Dispose(Boolean disposing) in E:\XXXX\XXXX\frmMain.Designer.cs:line 20
at System.ComponentModel.Component.Dispose()
at XXXX.TestComponents.OpenComponentForTestting(stComponents TestComponent, stTestStepDetails Test, enExecutionModeTypes Mode, Boolean IsVisibleMode, Int32 nStepIndex, Int32 nTotalSteps) in E:\My Projects\XXXXXXXX\frmMDIContainer.cs:line 3145
会出现什么问题。 请帮帮我。
答案 0 :(得分:5)
我必须看一下代码才能确定,但也许我可以帮你找到合适的地方......
堆栈跟踪表示在Dispose序列期间正在重新绘制pictureBox中的动画。那么为什么图片盒试图在它应该死的时候这样做呢?
在这种情况下,您可能需要执行以下操作:在处理窗口之前关闭()窗口,干净地关闭窗口(例如,在调用base.Dispose()之前禁用图片框中的动画),或者可能还有其他您可以在安全地调用base.Dispose之前在类中创建并需要处理的资源。或者,您可能已经处置了仍然需要的东西(例如,PictureBox试图访问的图像) - 检查处理“组件”将实际处理的内容。