2

Whenever we close our application, there is an unhandled exception being raised that doesn't give us much detail on it's root cause:

{System.InvalidOperationException: Invoke or BeginInvoke cannot be called on a control until the window handle has been created.
at System.Windows.Forms.Control.MarshaledInvoke(Control caller, Delegate method, Object[] args, Boolean synchronous)
at System.Windows.Forms.Control.BeginInvoke(Delegate method, Object[] args)
at System.Windows.Forms.WindowsFormsSynchronizationContext.Post(SendOrPostCallback d, Object state)
at System.Windows.Forms.AxHost.ConnectionPointCookie.Finalize()}

I don't see anywhere in our code where we're calling BeginInvoke.

We are calling Invoke but only if InvokeRequired = True.

Has anyone ever seen this before?

BBousman
  • 83
  • 1
  • 8
  • Duplicate of [Invoke or BeginInvoke cannot be called on a control until the window handle has been created](http://stackoverflow.com/questions/808867/invoke-or-begininvoke-cannot-be-called-on-a-control-until-the-window-handle-has) – Bjørn-Roger Kringsjå Sep 02 '14 at 16:34
  • 1
    I tried the things on that page and it didn't help. Plus, that user had their own SafeInvoke method, I don't have anything like that. – BBousman Sep 02 '14 at 16:39
  • The root cause is you using a WebBrowser in your code that you don't dispose. – Hans Passant Sep 02 '14 at 16:54
  • We don't use a WebBrowser control in our code but we do have some WebRequests, is that what you meant? – BBousman Sep 02 '14 at 17:28

0 Answers0