English 中文(简体)
Is there a standard way for .NET Winforms apps to auto-upgrade?
原标题:

If you have a Winforms app that is installed on a large number of machines, is there a standard way of implementing an automatic upgrade function?

e.g. Each time it is started, it checks a web site or web service and if there is a new version available, it downloads and installs it?

I could figure out how to roll my own version of this, but I m wondering if there are any frameworks already in place to help with this.

最佳回答

+1 on the ClickOnce answer, but I wanted to make a few comments on that as well:

Normally, when someone first starts out looking at ClickOnce they discover that it adds a number of new restrictions to things that their app is allowed to do. They nearly always violate at least one of these and come back declaring that ClickOnce doesn t work for them because x,y, and z won t work anymore.

Anticipating this will once again be the case, I want to take a moment to explain a rationale for these restrictions and why you might want to take a closer look at the way your app functions rather than write your own update system or go with an alternative.

The key thing here is to look at the primary use case for ClickOnce apps. That use case is mainly corporate workstations, where you want to deploy a real winforms line of business app that should always be up to date, but under no circumstances should users ever have administrator access to their own machine. Since you re talking about an "app that is installed on a large number of machines", I think it s likely you re in that category.

Looking at this use case, the last point especially is killer. In the end, most of the little restrictions on ClickOnce apps are things that would require one of the following:

  1. Administrator access at run time, even briefly
  2. Administrator access at update time

Sometimes it s not obvious that you need that access or why you need that access, but in the end that s usually what it comes down to. Want to register a dll with the system or update a file in the Program Files folder? That requires administrator access by default. Need to install or update a windows service? Administrator access. Want to run an msi installer for a third party component? You need Admin privileges to run msi s. Want to listen on a tcp port? You get the idea.

In the end, your goal is to make it so that even users with only standard privileges will still be able to update your app automatically... even transparently. Otherwise, you need extra IT staff involved with every deployment. This is a good idea even if your program is for the public at large; it will help you avoid a certain class of support issue. Going with an alternative deployment system won t change this. Those systems are just typically targeted at consumer machines where most users run as administrator anyway and so are less up front about the issues.

问题回答

You may want to try out ClickOnce, I think it s possible with that.

AppLife Update is worth every cent it costs.

I eventually used the Open Source Conversive Sharp AutoUpdater at

http://csautoupdater.sourceforge.net/

Sharp AutoUpdater is a C# component that will automatically update your .NET application. Using XML configuration files, the AutoUpdater component detects if there is a new version of the software, downloads, unzips, and installs the new files.

Its fairly simpe - it downloads a zip and unzips it over the installed app - but it works well and was easier than writing my own. I don t think it handles things very well if users dont have admin access to their program files folder.





相关问题
Bring window to foreground after Mutex fails

I was wondering if someone can tell me what would be the best way to bring my application to the foreground if a mutex was not able to be created for a new instance. E.g.: Application X is running ...

How to start WinForm app minimized to tray?

I ve successfully created an app that minimizes to the tray using a NotifyIcon. When the form is manually closed it is successfully hidden from the desktop, taskbar, and alt-tab. The problem occurs ...

Linqy no matchy

Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...

Handle DataTable.DataRow cell change event

I have a DataTable that has several DataColumns and DataRow. Now i would like to handle an event when cell of this DataRow is changed. How to do this in c#?

Apparent Memory Leak in DataGridView

How do you force a DataGridView to release its reference to a bound DataSet? We have a rather large dataset being displayed in a DataGridView and noticed that resources were not being freed after the ...

ALT Key Shortcuts Hidden

I am using VS2008 and creating forms. By default, the underscore of the character in a textbox when using an ampersand is not shown when I run the application. ex. "&Goto Here" is not ...

WPF-XAML window in Winforms Application

I have a Winforms application coded in VS C# 2008 and want to insert a WPF window into the window pane of Winforms application. Could you explain me how this is done.

热门标签