How to manually update clickonce (including code)

Source: Internet
Author: User

The default value is automatic update, But I think manual update is more rational.
To manually update an instance, you only need to disable the "the application shocould check for updates" option in update.
Therefore, manually updatedCodeThis code is from the eLearning video. I wrote it down and shared it with you.

1 If (Applicationdeployment. isnetworkdeployed =   True )
2 {
3 Applicationdeployment thisdeployment = Applicationdeployment. currentdeployment;
4 This . Text =   " Updating being detected " ;
5 If (Thisdeployment. checkforupdate () =   True )
6 {
7 If (MessageBox. Show ( " It is detected that a new version can be updated. Do you need to update it now? " , " Select whether to update " , Messageboxbuttons. yesno, messageboxicon. Information) = Dialogresult. Yes)
8 {
9 This . Text =   " Updating... " ;
10 Thisdeployment. Update ();
11 MessageBox. Show ( " Update completed and will be restartedProgram! " );
12 Application. Restart ();
13 }
14 Else
15 {
16 This . Text = Application. productname +   "   "   + Application. productversion;
17 }
18 }
19 Else
20 {
21MessageBox. Show ("No new version is available!");
22}
23 }
24 Else
25 MessageBox. Show ( " This is not a program released on the network. " );

Clickonce is indeed very convenient, making winfrom easy to deploy and update. however, in my actual use, I found that it was still somewhat unstable and prone to errors during release. after VS was disabled, I could compile it again. However, the version was automatically downgraded to a level, I hope vs SP1 can correct these errors...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.