InvalidOperationException from GoView thread

Hi,



We have FlowControl which contains GoView. (we add it with the winform designer).

We have scenario where we need to create new FlowControl instead of old one.

The old FlowControl is now disposed along with its children components(including GoView)

However after or while creating the new FlowControl we get the following Exception from some background thread:



Unhandled exception

Exception thrown:

System.InvalidOperationException: Invoke or BeginInvoke cannot be called on a control until the window handle has been created.

at System.Windows.Forms.Control.WaitForWaitHandle(WaitHandle waitHandle)

at System.Windows.Forms.Control.MarshaledInvoke(Control caller, Delegate method, Object[] args, Boolean synchronous)

at System.Windows.Forms.Control.Invoke(Delegate method, Object[] args)

at System.Windows.Forms.Control.Invoke(Delegate method)

at Northwoods.Go.GoView.hoverCallback(Object obj)

at System.Threading._TimerCallback.TimerCallback_Context(Object state)

at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)

at System.Threading._TimerCallback.PerformTimerCallback(Object state)



If we don’t call dispose on FlowControl, the exception doesn’t appear.



Thanks in advance,

Aaron

What version are you using? 4.1 has a fix for this.

We are using version 3.0.3

Currently we are in a Release Candidate stage of our product, thus an upgrade is not an option.



Is there a workaround for this issue?



Thanks.

Catch the exception and ignore it, perhaps.

I am getting the same exception a occasionally.
I am using 4.1.0.4

System.InvalidOperationException: Invoke or BeginInvoke cannot be called on a control until the window handle has been created. at System.Windows.Forms.Control.WaitForWaitHandle(WaitHandle waitHandle) at System.Windows.Forms.Control.MarshaledInvoke(Control caller, Delegate method, Object[] args, Boolean synchronous) at System.Windows.Forms.Control.Invoke(Delegate method, Object[] args) at Northwoods.Go.GoView.hoverCallback(Object obj) at System.Threading._TimerCallback.TimerCallback_Context(Object state) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx) at System.Threading._TimerCallback.PerformTimerCallback(Object state)

I really thought I had nailed that one down. Can you tell me what’s happening in the app (and your code) when this happens? Do you create/delete a lot of GoViews?

It happens when we are removing GoDocuments, some of which may have a view open that is closed when its document gets deleted.

we do a “IsHandleCreated” before doing the Invoke. Must not be enough for some reason.

I’ve added an explicit catch for that exception, it will be in the next release.