.NET Framework Developer Center >
.NET Development Forums
>
Windows Presentation Foundation (WPF)
>
Application Auto-Update Question
Application Auto-Update Question
- Hi,
I've written an application which will run constantly and from a remote location.
What I want to do is to have the application checking weekly for updates and if there's a newer version then update to the new version.
So what I need to know, what is the best way to go about doing this.
Obviously an application cannot update itself because it needs to be closed to update it.
What I was thinking was, having an application running that starts my application, and it checks weekly for an new update, if it finds it it closes my application, updates it and then restarts it with the update applied.
The way the update will be applied is to overwrite the application that's already there(while also keeping a backup of the old version just incase).
So would this be the best way to do something like this - anyone got any other suggestions or point me to some sites that can help me do this.
Thanks alot,
Eoin...
Answers
- Hi Eoin,
ClickOnce has done about 90% of the work for you there already. If you can publish your app as a ClickOnce app, you can simply tell it to check for updates every 7 days from an arbitrary URL you specify, then write an app to restart your ClickOnce app when it updates itself.
Interesting ClickOnce update article here.
Simply go to your project properties, "Publish" tab, and click "Updates". You'll want to select "The Application should check for updates", the "After the application starts" option (since the "before" option will require user intervention). Additionally you can programatically check for updates whenever you like. When updates are available, you can programatically apply them. There's a good sample of that here: http://msdn.microsoft.com/en-us/library/ms404263(VS.80).aspx .
Once you've updated your app, you will need to restart it. Here's where the extra 10% of work comes in. You'll want to write an app (could even include this as a "content" file with your CLickOnce deployment) that runs on this machine, and monitors for when your app's process closes. When you detect an update, you'd want to start this process via Process.Start(), then simply call Application.Current.Shutdown();. When the process exits, the special "restarter" app can just re-invoke it via its shortcut in the start menu (.appref-ms.... clickonce apps are special like that)... and you have your self-sustaining app update scenario.
Hope this helps,
Matt
SDET : Deployment/Hosting- Marked As Answer byIrishJoker Friday, June 06, 2008 8:53 PM
- Unmarked As Answer byIrishJoker Friday, June 06, 2008 9:27 PM
- Marked As Answer byIrishJoker Friday, June 06, 2008 10:11 PM
- Not true, our application runs in full trust and is deployed via click-once. There are two different types of WPF click-once applications; normal EXEs and XBAPs. XBAPs are click-once deployed inside the browser and thus run in a sandbox.
- Marked As Answer byIrishJoker Friday, June 06, 2008 10:11 PM
All Replies
- Hi Eoin,
ClickOnce has done about 90% of the work for you there already. If you can publish your app as a ClickOnce app, you can simply tell it to check for updates every 7 days from an arbitrary URL you specify, then write an app to restart your ClickOnce app when it updates itself.
Interesting ClickOnce update article here.
Simply go to your project properties, "Publish" tab, and click "Updates". You'll want to select "The Application should check for updates", the "After the application starts" option (since the "before" option will require user intervention). Additionally you can programatically check for updates whenever you like. When updates are available, you can programatically apply them. There's a good sample of that here: http://msdn.microsoft.com/en-us/library/ms404263(VS.80).aspx .
Once you've updated your app, you will need to restart it. Here's where the extra 10% of work comes in. You'll want to write an app (could even include this as a "content" file with your CLickOnce deployment) that runs on this machine, and monitors for when your app's process closes. When you detect an update, you'd want to start this process via Process.Start(), then simply call Application.Current.Shutdown();. When the process exits, the special "restarter" app can just re-invoke it via its shortcut in the start menu (.appref-ms.... clickonce apps are special like that)... and you have your self-sustaining app update scenario.
Hope this helps,
Matt
SDET : Deployment/Hosting- Marked As Answer byIrishJoker Friday, June 06, 2008 8:53 PM
- Unmarked As Answer byIrishJoker Friday, June 06, 2008 9:27 PM
- Marked As Answer byIrishJoker Friday, June 06, 2008 10:11 PM
- Ah cheers man,
Had heard anout the ClickOnce thing, but didn't really know what it was about.
Thanks for your help,
Eoin... - I was reading the links you sent me.
It looks like ClickOnce applications run in a sand-box mode.
I actually need a full trust application because I'll be reading and writing files/directories to the file system.
So unfortunately this doesn't seem to be what I'm looking for.
Is there a different way to use the ClickOnce model ??
Thanks
Eoin... - Not true, our application runs in full trust and is deployed via click-once. There are two different types of WPF click-once applications; normal EXEs and XBAPs. XBAPs are click-once deployed inside the browser and thus run in a sandbox.
- Marked As Answer byIrishJoker Friday, June 06, 2008 10:11 PM
- Paul is correct. Further, xbaps under special setups can actually run with full trust. I just want to add that the only kind of WPF ClickOnce app that can actually check for updates is the standalone app, since this is the only "installed" clickOnce app. Since it doesnt run in the browser and has to create windows, it's not just full-trust by default, it is actually blocked from running in partial trust. (Since the WPF window has a security demand for permissions outside the Internet / Intranet zones).
-Matt
SDET : Deployment/Hosting - Well my application will be an installed application so it should be ok then.
I'll read up more on ClickOnce.
Your help was much appreciated.
Thanks again lads,
Eoin...


