AutomaticUpdaterBackend, wyUpdate crashSolved

Hey guys,

So far your solution has worked well for me, but recently updating has become temperamental. I'm using AutomaticUpdaterBackend, to launch the updates and sometimes wyUpdate updates properly, sometimes it fails silently. I haven't noticed a pattern to when it does or doesn't fail, but it almost always works fine when the debugger is running, breakpoints or no.

Here's some code:

private static AutomaticUpdaterBackend _auBack = null;

public static AutomaticUpdaterBackend AutomaticUpdaterBackend { get { return _auBack ?? (_auBack = new AutomaticUpdaterBackend { GUID = "my_guid_here", UpdateType = UpdateType.Automatic }); } }

[STAThread] public static void Main(string[] args) { bool failure = false; ManualResetEvent allowContinue = new ManualResetEvent(false); AutomaticUpdaterBackend.BeforeDownloading += delegate(object sender, BeforeArgs e) { if (failure) { e.Cancel = true; return; } Log.Info(Properties.Resources.UPDATE_AVAILABLE); }; AutomaticUpdaterBackend.ReadyToBeInstalled += delegate { if (AutomaticUpdaterBackend.UpdateStepOn == UpdateStepOn.UpdateReadyToInstall) { if (!failure) AutomaticUpdaterBackend.InstallNow(); } }; AutomaticUpdaterBackend.UpToDate += delegate(object sender, SuccessArgs e) { allowContinue.Set(); };

FailHandler failHandler = delegate(object sender, FailArgs e) { failure = true; if (e.ErrorMessage != null) { Log.Error(e.ErrorMessage); } allowContinue.Set(); }; AutomaticUpdaterBackend.CheckingFailed += failHandler; AutomaticUpdaterBackend.DownloadingFailed += failHandler; AutomaticUpdaterBackend.ExtractingFailed += failHandler; AutomaticUpdaterBackend.UpdateFailed += failHandler;

AutomaticUpdaterBackend.Initialize(); AutomaticUpdaterBackend.AppLoaded();

if (!AutomaticUpdaterBackend.ClosingForInstall && AutomaticUpdaterBackend.UpdateStepOn == UpdateStepOn.Nothing) { AutomaticUpdaterBackend.ForceCheckForUpdate(); }

allowContinue.WaitOne(); }

Sorry for the format, I couldn't get BBCode on.

Hey Jeff,

Looking at your code, it seem alright -- that is, you're doing everything right. What type of "silent failure" are you having? Is your app crashing? Are any of the failure events being called? Where is the problem happening?

Also, you say wyUpdate is crashing -- at what point? That is, has checking begun? when it's downloading? When it's extracting? When it's installing your new version? Also, is it really crashing -- is it still running in the background (open the task manager and see)?

What version of wyUpdate and the AutomaticUpdater are you using? Please don't just assume you're using the latest version. Actually right click each file in your binaries folder, click properties, and tell me each version number.

The code is a start, but I need a whole lot more information to track down the problem.

wyUpdate.exe version: 2.6.11.3AutoUpdater.dll (.Net 4): 2.6.11.2

No error events are fired, the updater checks and downloads just fine. ReadyToBeInstalled is fired and I wait on my handle for the program to be closed. I can see wyUpdate run for a split second then disappear. It doesn't trigger my program to restart when it does this. The next time I run my program, there are still no errors fired. And it may attempt to install again immediately, or it may fire BeforeDownloading first.

It seems more likely to fail this way after having done it once, but I don't have solid statistics to back that up.

Edit: Oh yes, and the wyUpdate.exe process does indeed stop.

I'll try to replicate this behavior. What OS are you running (XP, Windows 7 x64, etc)? And how much RAM does your computer have. Also, how many cores does your CPU have?

Win7 Ultimate 32 bit2 GB RamIntel Pentium Dual Core

My client and their customers have experienced this on their systems as well.

We can't reproduce this. I used the code you posted and I've tried the update around 20+ times and the update succeeds everytime. Can we schedule a time to do a remotely diagnose this on your computer? Contact me at wyatt@wyday.com

We've also been seeing this on and off over the last two months. Its has been hard to pin down, and we can't get permission to send you our source, which makes both our lives hard.

The symptoms are very similar to what's been described. On some machines, sometimes, wyUpdate does not restart. We just can't pin it down. We've seen it across Win7, WinXP, Vista and 64 bit Win7. Some have anti-virus, some don't. We've tried different ways of using wyUpdate, Form closing handlers, delays on shutdown, but none made much difference.

So to quote Jeff:"ReadyToBeInstalled is fired and I wait on my handle for the program to be closed. I can see wyUpdate run for a split second then disappear. It doesn't trigger my program to restart when it does this. "We see exactly this. wyUpdate gets to the second tick box and then dies.

"The next time I run my program, there are still no errors fired."Next time we run our program, wyUpdate runs fine and applies the update and everything's good.

We can live with it, but it would be nice if we could fine out why wyUpdate is killing itself sometimes on the first update.

Jeff, did you get my email?

Hey Andrew,

With Jeff's assistance I was able to reproduce the bug. We'll have the fix included with the next version of wyUpdate. We're shooting for a release this Friday.

Thanks for your help Wyatt. I'll look forward to the update.

Thanks, Wyatt and Jeff.This is great news! Your support is excellent.What was the cause?

What was the cause?

It was a race condition. When wyUpdate is in "AutoUpdate mode" it listens to the commands of the AutomaticUpdater. So when your app closes (either gracefully or crashes) then wyUpdate closes. This is all by design.

When the AutomaticUpdater tells wyUpdate to begin installing the new update your app closes (by design) and wyUpdate prepares for installation. The problem you guys were getting was the race condition between wyUpdate closing when you app closes and setting the "InstallingNowDontClose" bool.

With the race condition sometimes the update installed fine, sometimes it looks like wyUpdate crashed.

We're fixing this now, and it's turning out to be a remarkably simple fix considering how much trouble the bug was causing.

Thanks for the explanation. It makes sense and explains what we see.

wyBuild 2.6.12 is now out -- this bug has been fixed.