About the .NET service installation

xiaoxiao2021-03-06  39

Originally, I wanted to install the service program from process.strat (), but when debugged, it can be executed after the release, I don't report anything wrong, statement process.strat (...) Executed, it can't be installed, it may be no right. Later, I found a few classes in .NET, you can use: TransactedInstaller and AssemblyInstallertransactedInstaller are used to install multiple AssemblyInstaller, I only use AssemblyInstaller enough! To reference System.Configuration.Install.dll and using System.Configuration.Install; easy installation: AssemblyInstaller myAssemblyInstaller; myAssemblyInstaller = new AssemblyInstaller (); myAssemblyInstaller.UseNewContext = true; myAssemblyInstaller.Path = "XXXService.exe"; Hashtable mySavedState = New hashtable () MyassemblyingInstaller.install (mysavedState); myassemblyinstaller.commit (mysavedState); myassemblyinginstaller.dispose ();

Unloading service: AssemblyInstaller myAssemblyInstaller; myAssemblyInstaller = new AssemblyInstaller (); myAssemblyInstaller.UseNewContext = true; myAssemblyInstaller.Path = "XXXService.exe"; myAssemblyInstaller.CommandLine = new string [1] { "/ u"}; myAssemblyInstaller.Uninstall (null MyassemblyingInstaller.dispose ();

These 2 classes should also make some small installations!

转载请注明原文地址:https://www.9cbs.com/read-66306.html

New Post(0)