標籤:ar io 使用 sp on art bs cti amp
1. 建立windows服務【引用博文】:
1. 將這個服務程式切換到設計檢視
2. 右擊設計檢視選擇“添加安裝程式”
3. 切換到剛被添加的ProjectInstaller的設計檢視
4. 設定serviceInstaller1組件的屬性:
1) ServiceName = My Sample Service
2) StartType = Automatic
5. 設定serviceProcessInstaller1組件的屬性
1) Account = LocalSystem
6. 產生解決方案
注意:嘗試同時啟用多服務,個人測試並沒有成功!
ServiceBase[] ServicesToRun;
ServicesToRun = new ServiceBase[]
{
new NFSMainService()
};
ServiceBase.Run(ServicesToRun);
ServiceBase[] 數組中放多個服務時,只能運行第一個,看了許多博文但未能解決,不過我們可以將多個服務以類的形式放到一個服務中。
2.安裝服務有兩種方法:
1.通過InstallUtil程式去安裝:通過開啟Visual Studio .NET命令,格式:路徑 InstallUtil.exe MyWindowsService.exe;
卸載的話:格式:路徑 InstallUtil.exe MyWindowsService.exe /u
但如果到客戶方部署的話,生產環境未必有Visual Studio .NET命令,這種情況我們可以打包服務,也可以使用cmd命令:
sc create 服務名字 binPath= E:\Test\WindowsApplication1\WindowsService1\bin\Debug\ WindowsService1.exe,斷行符號;
binPath=後面需要加空格。
卸載:
SC delete 服務名字
.net建立並安裝windows案例