我正在使用 prism 框架 [.net 4.0] 开发一个 wpf 应用程序。我使用 StockTrader RI 中的 RegionPopupBehavior 实现了一个弹出窗口。现在,当我使用窗口标题栏 [主窗口] 右上角的关闭按钮或使用
Application.Current.Shutdown()
在单击按钮时调用,我收到带有消息“无效窗口句柄”的 win32 异常,并且堆栈跟踪是所有互操作调用返回到应用程序 Run() 调用。
我已经搜索谷歌和 SO 来寻找答案,但无济于事。我在关闭期间设置了中断并检查了 Windows 集合,但它仅将主窗口显示为活动的[如果弹出窗口被隐藏]。请注意,当我点击关闭时,无论弹出窗口是否打开,我都会收到错误消息。
这是堆栈跟踪:
at MS.Win32.HwndWrapper.DestroyWindow(Object args)
at MS.Win32.HwndWrapper.Dispose(Boolean disposing, Boolean isHwndBeingDestroyed)
at MS.Win32.HwndWrapper.Dispose()
at System.Windows.Interop.HwndSource.Dispose(Boolean disposing)
at System.Windows.Interop.HwndSource.WeakEventDispatcherShutdown.OnShutdownFinished(Object sender, EventArgs e)
at System.EventHandler.Invoke(Object sender, EventArgs e)
at System.Windows.Threading.Dispatcher.ShutdownImplInSecurityContext(Object state)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Windows.Threading.Dispatcher.ShutdownImpl()
at System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame)
at System.Windows.Threading.Dispatcher.PushFrame(DispatcherFrame frame)
at System.Windows.Threading.Dispatcher.Run()
at System.Windows.Application.RunDispatcher(Object ignore)
at System.Windows.Application.RunInternal(Window window)
at System.Windows.Application.Run(Window window)
at System.Windows.Application.Run()
at RNDGroup.App.App.Main() in c:\Users\jgilliland\Projects\Common\Source\Prism GUI\RNDGroup.App\obj\x86\Release\App.g.cs:line 0
at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
我的问题是,如果有人在类似情况下见过它,我该如何解决这个问题,或者我该如何进一步调试这个 win32 异常?谢谢,j