自動更新解決方案

來源:互聯網
上載者:User
由於boss不讓使用smart client,所以只好使用下載-覆蓋-重啟應用程式的三步驟

首先,我們需要一個Loader程式,來引導主程式

http://files.cnblogs.com/wildfish/AppUpdateStarter.rar

第二,在主程式中
//擷取船塢系統的程式集

            //注意區分大小寫

            Assembly asm = Assembly.LoadFrom(Application.StartupPath + Path.DirectorySeparatorChar + "SD.dll");

            //擷取版本資訊

            string curVersion = VersionConfig.GetVersion(asm);

            //確認視窗

            Form_UpdateConfirm confirmForm = new Form_UpdateConfirm();

            //校正版本對象            

            CheckVersionSystem checkVersion = new CheckVersionSystem(confirmForm, "SDSYSTEM", curVersion, Application.StartupPath, false);

            bool needRestart = false;

            //更新狀態視窗

            Form_UpdateState stateForm = new Form_UpdateState(checkVersion);

            //判斷版本,嘗試升級            

            checkVersion.TryUpdate(ref needRestart);


            //如果需要重新啟動

            if (needRestart)

            {

                Environment.ExitCode = 2; //the surrounding AppStarter must look for this to restart the app.

                MessageBox.Show("提示:系統更新完畢!請重新啟動!", "更新完畢");

            }

            else

            {

                Form_SD_Main doc_SD = new Form_SD_Main();

                Application.Run(doc_SD);

            }

第三步,安裝程式要按照如下目錄方式來製作

外層的目錄,一個Loader程式,一個設定檔,應用程式的檔案夾


這個是Penavicoxm檔案夾內部的內容


這樣我們就可以可控的控制應用系統的升級

當然了這種方式存在一種缺點,不能及時有效讓使用者更新,使用者只有重新進入系統的時候才會體現更新

如果為了比較及時地,最好使用smart client,或者用b/s架構:)

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.