4

我在visual studio 2013中使用c#創建了一個窗口服務。 Windows服務正常工作。執行使用Visual Studio創建的* .msi文件時出錯

當我創建一個安裝項目,並運行在不同的計算機.msi文件它給了我一個錯誤

Error

步驟我做:

1.右鍵單擊解決方案 - >其他項目類型 - > Visual Studio安裝程序 - 設置項目

2.添加名稱文件系統編輯器 - >選擇應用程序文件夾 - >右鍵單擊 - >添加 - >項目輸出 - >添加項目輸出組彈出 項目:選擇我的項目,主輸出

File system editor

  • 選擇自定義動作編輯器 - >安裝 - >右鍵 - >添加自定義操作 - >選擇應用程序文件夾和項目輸出。
  • 重複相同的用於卸載

    Custom Actions Editor

  • 生成安裝程序。
  • .msi和setup.exe文件在該文件夾中創建。

    我看到https://www.youtube.com/watch?v=cp2aFNtcZfk教程做到這一點。

    可以告訴我如何解決這個問題。

    感謝


    編輯:我有projectInstaller在我的項目

    namespace certify4byd_ver2._0 
    { 
    partial class ProjectInstaller 
    { 
    
        private System.ComponentModel.IContainer components = null; 
    
        protected override void Dispose(bool disposing) 
        { 
         if (disposing && (components != null)) 
         { 
          components.Dispose(); 
         } 
         base.Dispose(disposing); 
        } 
    
    
        private void InitializeComponent() 
        { 
         this.serviceProcessInstaller1 = new System.ServiceProcess.ServiceProcessInstaller(); 
         this.serviceInstaller1 = new System.ServiceProcess.ServiceInstaller(); 
         // 
         // serviceProcessInstaller1 
         // 
         this.serviceProcessInstaller1.Account = System.ServiceProcess.ServiceAccount.LocalService; 
         this.serviceProcessInstaller1.Password = null; 
         this.serviceProcessInstaller1.Username = null; 
    
         // 
         // serviceInstaller1 
         // 
         this.serviceInstaller1.Description = "Quick Source specific development to allow ftp files to be send to ByDesign envir" + 
    "onment"; 
         this.serviceInstaller1.DisplayName = "Quick Source Certify4ByDesign"; 
         this.serviceInstaller1.ServiceName = "qs_certify4byd_v2.0"; 
         this.serviceInstaller1.StartType = System.ServiceProcess.ServiceStartMode.Automatic; 
         this.serviceInstaller1.AfterInstall += new System.Configuration.Install.InstallEventHandler(this.serviceInstaller1_AfterInstall); 
         // 
         // ProjectInstaller 
         // 
         this.Installers.AddRange(new System.Configuration.Install.Installer[] { 
         this.serviceProcessInstaller1, 
         this.serviceInstaller1}); 
    
        } 
    
        #endregion 
    
        private System.ServiceProcess.ServiceProcessInstaller serviceProcessInstaller1; 
        private System.ServiceProcess.ServiceInstaller serviceInstaller1; 
        } 
    } 
    
    +0

    看看https://stackoverflow.com/questions/9021075/how-to-create-an-installer-for-a-net-windows-service-using-visual-studio - 任何你已經也許失蹤? –

    +0

    @DirkVollmar:不,我沒有錯過任何東西。 – GameBuilder

    回答

    0

    從錯誤信息,它看起來就像你複製你的應用程序文件複製到目標機器,僅此而已。如果您正在編寫Windows服務,則需要執行其他步驟來獲取MSI程序包以將其作爲服務安裝。

    您的項目是否有ServiceInstaller類的地方?這就是.NET希望你安裝服務的方式。

    Visual Studio Installer項目可能不是最好的方式,至少在我的經驗。查看Debuggable Installable Service,它是Visual Studio的一個擴展,它允許您創建自行安裝的Windows服務(帶有命令行參數),該服務也是可直接進行控制檯調試的。在編寫服務時,這對我來說是一個救生員,因爲你並沒有搞亂ServiceInstaller,一切都爲你完成。

    我的另一個建議是,除了使用Debuggable Installable Service之外,請看WiX Toolset。它需要在計劃開發產品的任何地方安裝(如果您是在源代碼管理下開發的話,這有點痛苦),但它也允許您安裝服務,並使您能夠更細緻地控制應用程序的運行方式安裝。

    我不推薦Visual Studio安裝程序項目。

    +0

    我的項目中有Service Installer。請參閱已編輯區域。 感謝您提供其他工具。我曾在VS的安裝程序項目中使用過。我想我錯過了一些我無法覈實的東西。 – GameBuilder

    相關問題