0
我开发了一个WPF应用程序,在关闭应用程序时遇到问题。应用程序关闭异常
仅在Windows 2003 PC上,应用程序在关闭时会引发以下异常。但它似乎并没有从我的代码中抛出,因为我无法获得一个调用堆栈。
这就是为什么我不能发布任何进一步的细节。
你有什么线索可以开始挖掘它吗?
System.InvalidOperationException was unhandled
Message=Handle is not initialized.
Source=mscorlib
StackTrace:
at System.WeakReference.set_Target(Object value)
at System.Windows.Threading.Dispatcher.FromThread(Thread thread)
at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
at MS.Win32.UnsafeNativeMethods.IntDestroyWindow(HandleRef hWnd)
at MS.Win32.HwndWrapper.DestroyWindow(Object args)
at MS.Win32.HwndWrapper.Dispose(Boolean disposing, Boolean isHwndBeingDestroyed)
at MS.Win32.HwndWrapper.Finalize()
InnerException:
感谢您的意见。
编辑 我发现哪行代码产生失败。但我该如何解决它?
这是下面的代码行:
try
{
return DesignerProperties.GetIsInDesignMode(new DependencyObject());
}
catch (Exception)
{
return true;
}
我用这个来检查代码在设计运行。但是关闭这段代码失败了,尽管我发现了这个异常。
任何其他想法来检查设计模式? 感谢您的帮助。
那么mscorlib是.net框架核心库,看起来像你在那里有一个问题 - 弱引用看起来是罪魁祸首..但为什么是任何人猜测:)。您尝试创建一个没有代码的简单WPF应用程序,并关闭该应用程序,看看您是否遇到同样的问题? (当然在Win2003机器上) – Charleh 2012-08-07 13:13:59
请看我的编辑。我发现了错误,但不知道解决方法... – BitKFu 2012-08-07 13:24:33
之前,你问:我使用新的DependencyObject(),因为我想检查这在我的ViewModel – BitKFu 2012-08-07 13:27:49