Detailed C#winform Program Automatic Update implementation method

Source: Internet
Author: User
WinForm Program Automatic Update I was also the first to do, the Internet to find the source of Automatic Updates, and then according to some of the methods seen on the Internet, I have tried for a long time, eventually there is a write error, so spent money to help others to debug the success, the following is my own churn out, convenient for everyone to learn from, If there's anything wrong, please.

WinForm Program Automatic Update I was also the first to do, the Internet to find the source of Automatic Updates, and then according to some of the methods seen on the Internet, I have tried for a long time, eventually there is a write error, so spent money to help others to debug the success, the following is my own churn out, convenient for everyone to learn from, If there is anything wrong, please correct me.

1, since I was automatically updated through the server's IIS publishing, before updating the program manually copied to the IIS server directory, make some changes, the client to normal automatic update. So the first step is not ripe IIS server (my system windows8):

Follow the above method, then click OK, the system will automatically add the content, and then:

After the site has been established, put the files that need to be updated into the file directory of the physical path you choose to be OK.

2, the site has been established, then the following is to find ways to make updates, that is, from the server update files to the client, as to the specific process and the central idea I will not repeat, online a lot.

3, automatic source download address can not find, if necessary, please leave the mailbox, I send again.

4, the automatic source code generation class Library, and then in your main program reference the class library, put the two files and your main program under the same folder:

5, the main program call, in the main program called I was placed in the login form before, because I have no way to control whether the program needs to be updated, so I need to establish a process, that is, the database to build a table, including two fields

For example, the new field is saved with the most recent version, and old is the previous version.

Using mulaolao.forms;using mulaolao.procedure;using system;using system.collections.generic;using System.Linq;using System.threading.tasks;using system.windows.forms;using mulaolao.other;using system.threading;using StudentMgr; Using system.data;using system.data.sql;using system.data.sqlclient;namespace mulaolao{Static class Program {//  private static mutex mutex;  <summary>///The main entry point of the application.   </summary> [STAThread] static void Main () {application.enablevisualstyles ();   Application.setcompatibletextrenderingdefault (FALSE);   Read table datatable da = sqlhelper.executedatatable ("SELECT * from R_updatefororder");   String news = "", old = ""; If there is no data in the table, log in directly without updating the IF (DA.    Rows.Count < 1) {//Set login successful after closing the login form to display the main form login LG = new Login (); Lg.    StartPosition = Formstartposition.centerscreen; Lg.    ShowDialog (); if (LG.    DialogResult = = DialogResult.OK) {Application.Run (New Form1 ());    } else {return;   }} else{//If the new version in the table is consistent with the old version, you do not need to update the news = da. rows[0]["New"].    ToString (); Old = da. rows[0]["old"].    ToString ();     if (news = = old) {//Set login successful after closing the login form to display the main form login LG = new Login (); Lg.     StartPosition = Formstartposition.centerscreen; Lg.     ShowDialog (); if (LG.     DialogResult = = DialogResult.OK) {Application.Run (New Form1 ());     } else {return; }} else {//If the new version in the table is inconsistent with the old version, you will need to update the old version to a new version and start the Auto Update window sqlhelper.executenonquery ("Update R_updatefororde     R SET old= @Old ", New SqlParameter (" @Old ", News));    System.Diagnostics.Process.Start (Application.startuppath + @ "\autoupdate.exe"); }   }     } }}

Next, you will automatically start the updated main program when you are finished.

6, said updatelist.xml inside the main parameters:

Below this is the update version (the table in the new field) of the program, placed in the client, the third image in the version update folder inside, each update server before running this program, update the latest database version:

The above content is my own spent money toss out of the less advanced methods, no way, who let their entry soon, no experience, they can not make advanced to, welcome to correct me in time. In fact, the main step: First build the IIS server--new site--The main program files, update files, version updates a brain in the same folder, and the main program calls the update (mainly to determine when to automatically update)-- Configure the parameters in the automatic update file--the version in the database is built--before the update in the server overwrite the program, modify the automatic update XML file content, run version update--Wait for the client to update itself

Related Article

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.