bright, fresh software
Downloads  |  Buy

AutomaticUpdater exception

AutomaticUpdater exception

Postby Michael » July 28th, 2012, 7:03 pm

I'm getting the following exception from AutomaticUpdater control when my application starts:

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

Stack Trace:
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 wyDay.Controls.AutomaticUpdater.auBackend_ClosingAborted(Object sender, EventArgs e)
at wyDay.Controls.AutomaticUpdaterBackend.updateHelper_PipeServerDisconnected(Object sender, UpdateHelperData e)
at wyDay.Controls.UpdateHelper.bw_RunWorkerCompleted(Object sender, RunWorkerCompletedEventArgs e)
at System.ComponentModel.BackgroundWorker.OnRunWorkerCompleted(RunWorkerCompletedEventArgs e)
at System.ComponentModel.BackgroundWorker.AsyncOperationCompleted(Object arg)
at System.Threading._ThreadPoolWaitCallback.WaitCallback_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading._ThreadPoolWaitCallback.PerformWaitCallbackInternal(_ThreadPoolWaitCallback tpWaitCallBack)
at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback(Object state)

Looks like AutomaticUpdater calls Invoke on the owner form before the form's handle is created. You should wait until ownerForm.IsHandleCreated returns true before doing anything with the ownerForm. Please check this link:

http://msdn.microsoft.com/en-us/library/system.windows.forms.control.invokerequired.aspx

"In the case where the control's handle has not yet been created, you should not simply call properties, methods, or events on the control. This might cause the control's handle to be created on the background thread, isolating the control on a thread without a message pump and making the application unstable."

Waiting for a fix :-)
Michael
 

Re: AutomaticUpdater exception

Postby Wyatt » July 28th, 2012, 7:28 pm

What version of the AutomaticUpdater are you using? Right click the AutomaticUpdater.dll in your app's binary folder, click Properties, and then look at the version.
User avatar
Wyatt
Site Admin
 
Posts: 2563
Joined: July 11th, 2007, 10:30 pm
Location: New Hampshire

Re: AutomaticUpdater exception

Postby Michael » July 28th, 2012, 8:04 pm

2.6.16.0 from the latest wyBuild download.
Michael
 

Re: AutomaticUpdater exception

Postby Wyatt » July 30th, 2012, 2:03 am

I'll look into reproducing this.
User avatar
Wyatt
Site Admin
 
Posts: 2563
Joined: July 11th, 2007, 10:30 pm
Location: New Hampshire

Re: AutomaticUpdater exception

Postby Michael » July 30th, 2012, 7:46 pm

It might be hard to reproduce. We have fairly large application that loads 20 assemblies, over 15 meg of .dll files. It takes several seconds to start. I got it into a state where I couldn't debug our app or start it outside of VS because of that exception in auBackend_ClosingAborted. Had to delete wyUpdate AU folder to get it working again. Didn't encounter that problem since then. We distributed beta version of our application that includes AutomaticUpdater to about 100 customers. Our application logs all errors to our server, so we will see if any customers encounter this issue.

Still, IsHandleCreated check is needed before Invoke to make sure it's safe to call Invoke...
Michael
 

Re: AutomaticUpdater exception

Postby Wyatt » August 15th, 2012, 1:36 am

We've fixed this in AutomaticUpdater 2.6.18.
User avatar
Wyatt
Site Admin
 
Posts: 2563
Joined: July 11th, 2007, 10:30 pm
Location: New Hampshire

Re: AutomaticUpdater exception

Postby Michael » September 24th, 2012, 8:05 pm

[quote="Wyatt"]We've fixed this in AutomaticUpdater 2.6.18.[/quote]

Looks like it's still not fixed or maybe this is another related exception. We have published an update to our software that includes wyUpdate 2.6.18.4 and AutomaticUpdater 2.6.18.4. Here is the error some of our customers are getting:

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.Invoke(Delegate method, Object[] args) at wyDay.Controls.AutomaticUpdater.auBackend_UpdateFailed(Object sender, FailArgs e)
at wyDay.Controls.AutomaticUpdaterBackend.UpdateStepFailed(UpdateStepOn us, FailArgs args)
at wyDay.Controls.AutomaticUpdaterBackend.updateHelper_PipeServerDisconnected(Object sender, UpdateHelperData e)
at wyDay.Controls.UpdateHelper.ServerDisconnected()
at wyDay.Controls.PipeClient.Read()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
Michael
 

Re: AutomaticUpdater exception

Postby Sam » September 25th, 2012, 2:03 pm

Well, this is a different exception, but we'll fix this as well.
User avatar
Sam
 
Posts: 1992
Joined: March 8th, 2010, 3:01 am
Location: New Hampshire

Re: AutomaticUpdater exception

Postby Michael » September 25th, 2012, 3:50 pm

Thank you Sam. I investigated this problem and here how it happens:

1. AutomaticUpdater detects new update, downloads it and shows that the update will be installed on next start.
2. User shutdowns our application and starts it again.
3. AutomaticUpdater starts wyUpdate when our application is started while our application is still loading.
4. wyUpdate tries to update our application but our application is still loading.
5. wyUpdate shows that our application is running and asks to terminate the process.
6. auBackend_UpdateFailed in AutomaticUpdater is called and it calls Invoke on our main form. Exception is thrown because handle for our main form is not created yet (remember, our application is still loading).

Maybe AutomaticUpdater should not start wyUpdate immediately on application startup when the update is ready to be installed. I would suggest something like that:
1. AutomaticUpdater detects that the update has to be installed and requests application shutdown by firing CloseAppNow, making sure form handle is created before firing the event of course.
2. Application closes, and AutomaticUpdater in FormClosed event handler starts the update process by launching wyUpdate.

I don't want users to see wyUpdate "terminate process" dialog, it's very bad user experience. In our case it's shown because our application wasn't given enough time to fully load then shutdown before wyUpdate tried to update it.
Michael
 

Re: AutomaticUpdater exception

Postby Bartos » October 2nd, 2012, 3:39 am

We experience a similair problem. Is there any solution for it?

We use a splash win form window to allow user to make his options before loading the main window.
Closing splash window causes main window to be loaded.

The wyUpdate widget is placed on the main window.

wyUpdate downloads updates. With next app start the follwoing expection is thrown:

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

Any workaround?
Bartos
 

Next

Return to wyBuild, wyUpdate, & AutomaticUpdater Support