WPF: la interacción de la aplicación Windows Forms causa errores extraños

I have windows.forms application that create WPF window on button-click event handler. It calls "Show" method on WPF window instance.

WPF window starts to listen to parent window events and try to resize itself (setting left,top,width,height properties) when parent windows.forms window location is changed (WPF window visually follows Windows.Forms windows as it was pinned).

Everything works ok but for some reason I occasionally receive SEH exception was unhandled popup window:

   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) ...

It appears from time to time and it's hard to find out what I am doing wrong.

I also noticed, that WPF window and Windows.Forms window running on different threads.

¿Alguna idea?

preguntado el 08 de enero de 11 a las 17:01

1 Respuestas

Let me answer myself.

Finally, I stopped fighting with Windows.Form <-> WPF Window integration, refactored WPF Window into WPF User Control and put it into standard Windows.Forms ElementHost (just dragged component from the toolbox onto wrapper Windows.Form instance).

Now everything is ok!

Respondido el 08 de enero de 11 a las 22:01

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.