Search code examples
c#upgradepatch

I don't "get" how a program can update itself. How can I make my software update?


Say I make an .exe file and everything is peachy. Wonderful it works.

Say I worked on a new feature on the software and I want it to be available for people who already have the older version, how can I make the software find my new version, patch it, and then go about it's business.

I can't seem to wrap my head around the issue.

Thank you.

EDIT: I'm sorry for the confusion, but I was meaning a more code-wise answer. Is there something special in my code I should have to allow updating?

For example, if I want to add a new feature, how can I add a "method" to an already packaged .exe? :S That has me in a swivel.


Solution

  • You need to look at Click Once Deployment.

    ClickOnce is a deployment technology that enables you to create self-updating Windows-based applications that can be installed and run with minimal user interaction. Visual Studio provides full support for publishing and updating applications deployed with ClickOnce technology if you have developed your projects with Visual Basic and Visual C#.

    This creates a downloadable setup exe which you load up to the web. The user either runs this in place or downloads and runs it. This wraps your exe in the code that will check the web location (at a frequency of your choosing) for updates. If it finds one it will install it for the user.

    You don't have to make any special changes to your code to enable this. beyond incrementing the version number. Just modify and extend your code as normal, compile, build, package and upload.

    One thing to note is though that ClickOnce doesn't support installing applications that require administrative access:

    ClickOnce deployment enables non-administrative users to install and grants only those Code Access Security permissions necessary for the application.

    So if your application requires admin level access to run or even install then it's not the solution for you.