I try to automate a Winforms form using the Application.ShowForm method. But this results in a System.InvalidOperationException:
I also tried it using a delegate. E.G.:Additional information: Ungültiger threadübergreifender Vorgang: Der Zugriff auf das Steuerelement BrowserForm erfolgte von einem anderen Thread als dem Thread, für den es erstellt wurde.
Code: Select all
delegate Ranorex.Form ShowFormDelegate(System.Windows.Forms.Form i_form);
...
m_clientForm = (Ranorex.Form)browser.Invoke(new ShowFormDelegate(Application.ShowForm), browser);
Unfortunately the result is the same:
The call stack of the exception:A first chance exception of type 'System.InvalidOperationException' occurred in System.Windows.Forms.dll
Additional information: Ungültiger threadübergreifender Vorgang: Der Zugriff auf das Steuerelement BrowserForm erfolgte von einem anderen Thread als dem Thread, für den es erstellt wurde.
What am I doing wrong?> System.Windows.Forms.dll!System.Windows.Forms.Control.Handle.get() + 0xdf bytes
System.Windows.Forms.dll!System.Windows.Forms.Control.SetVisibleCore(bool value = true) + 0xcb bytes
System.Windows.Forms.dll!System.Windows.Forms.Form.SetVisibleCore(bool value = true) + 0xb7 bytes
System.Windows.Forms.dll!System.Windows.Forms.Control.Visible.set(bool value) + 0xe bytes
System.Windows.Forms.dll!System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(int reason = -1, System.Windows.Forms.ApplicationContext context = {System.Windows.Forms.ApplicationContext}) + 0xee bytes
System.Windows.Forms.dll!System.Windows.Forms.Application.ThreadContext.RunMessageLoop(int reason, System.Windows.Forms.ApplicationContext context) + 0x53 bytes
System.Windows.Forms.dll!System.Windows.Forms.Application.Run(System.Windows.Forms.Form mainForm) + 0x2e bytes
RanorexNet.dll!Ranorex.Application.ShowForm.AnonymousMethod() + 0x2c bytes
mscorlib.dll!System.Threading._ThreadPoolWaitCallback.WaitCallback_Context(object state) + 0x2f bytes
mscorlib.dll!System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state) + 0x81 bytes
mscorlib.dll!System.Threading._ThreadPoolWaitCallback.PerformWaitCallback(object state) + 0x6c bytes
Thanks,
Stefan