2011-01-08 72 views
0

我有windows.forms應用程序在按鈕單擊事件處理程序上創建WPF窗口。它調用WPF窗口實例上的「Show」方法。當父窗口的窗口位置被改變時,WPF窗口開始偵聽父窗口事件並嘗試調整自身的大小(設置左,頂,寬,高屬性)(WPF窗口在視覺上跟隨Windows.Forms窗口,因爲它是固定)。WPF:Windows窗體應用程序交互導致奇怪的錯誤

一切工作正常,但由於某種原因,我偶爾會收到SEH exception was unhandled彈出窗口:

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.Run(Form mainForm) ... 

看來不時,很難找出什麼我做錯了。

我也注意到,WPF窗口和Windows.Forms窗口運行在不同的線程上。

任何想法?

回答

0

讓我來回答我自己。最後,我停止了與Windows.Form <戰鬥 - > WPF窗口集成,將WPF窗口重構爲WPF用戶控件,並將其放入標準的Windows.Forms中ElementHost(只需將組件從工具箱拖到包裝Windows.Form實例上) 。

現在一切正常!

相關問題