2

Possible Duplicate:
Suggest a method for auto-updating my C# program

I'm sorry if this question has been asked already. i have a problem whit online update because i don't know how can add code for check for update program and after check if find newer version upgrade itself.

However, every time I make changes to the program people will have to download the new version.

i have a host and no any problem whit host. well only i need add code for check for online update

how can add code for check for update when open program ? what can i do ? what do i do ? can u please help me ?

please give me sample code or sample project for understand. thanks.

Community
  • 1
  • 1
King Tohi
  • 199
  • 1
  • 1
  • 8
  • 4
    Evidently you didn't search before you asked. Duplicate of http://stackoverflow.com/questions/780594/how-can-i-make-my-c-sharp-application-check-for-updates and http://stackoverflow.com/questions/2956599/self-update-in-net-programs and probably several more. – Polynomial Nov 08 '11 at 13:56
  • See [Suggest a method for auto-updating my C# program](http://stackoverflow.com/questions/555118/suggest-a-method-for-auto-updating-my-c-sharp-program) – Matthew Flaschen Nov 08 '11 at 13:58

2 Answers2

4

Have you looked at the ClickOnce technology? This is automatically built-in to either

1) not check for updates
2) check for updates before the application starts or
3) check for updates after the application finishes.

It's a great way to circumvent your issues, and it's easy to implement.

Or if you want to manually do this, utilize the System.Reflection namespace and use the Assembly.GetExecutingAssembly().GetName().Version property to get the application's version. Then do whatever conditional comparison you need to do to see if that's the newest version, and if not then update the application.

1

When I wanted to implement something like this I made it really simple.

I downloaded a xml configuration file, parsed the file, and if xml document contained an update my program would download the file from my website. I broke up the xml document into files. Since you are able to get the version of assembly this was an effective way of doing it.

Since you have not even attempted to do it I will leave actually doing it as an exercise for you.

Security Hound
  • 2,577
  • 3
  • 25
  • 42
  • Why use a custom mechanism when ClickOnce is so easily used? In your case you've got a lot more work than just a couple of changes to the project settings. – Polynomial Nov 08 '11 at 14:00
  • @Polynomial - I wrote what I described 5 years ago. I also didn't understand how to create and publish a ClickOnce installer. In my case I also integrated a browser into my program and wrote a seperate updater application. – Security Hound Nov 08 '11 at 14:10
  • That doesn't mean you should suggest it to anyone, let alone a novice programmer. – Polynomial Nov 08 '11 at 14:11
  • @Polynomial - It served my purpose and I wanted to share what I did, just because you disagree, does not mean its an invalid answer. – Security Hound Nov 09 '11 at 12:56
  • I don't disagree that it's a valid mechanism for updating. It works, and it will do what OP wants. However, it's not good practice when there's a standardised mechanism for updates. It's even worse practice to recommend a non-standard mechanism to a novice programmer. It just gives *them* bad practices. – Polynomial Nov 09 '11 at 13:49
  • @Polynomial - Who says the person is novice? OneClick is not a solution, it only works if you have the ability to publish it, which like I explained I didn't. – Security Hound Nov 10 '11 at 12:04
  • I looked through the OP's previous questions, and the level of them suggests someone who isn't particularly experienced with programming. Since the OP did not specify that publishing was not possible, the best general solution should be used. Another solution should only be considered in exceptional circumstances. – Polynomial Nov 12 '11 at 17:53
  • @Polynomial - Can we please end this discussion. There is nothing wrong with my answer. – Security Hound Nov 14 '11 at 16:15
  • We shall agree to disagree and finish this discussion. – Polynomial Nov 14 '11 at 16:17