【发布时间】:2011-11-14 22:34:59
【问题描述】:
作为安装 Windows 服务的一部分,我编写了 installutil 和命令行的替代方案:
IDictionary state = new Hashtable();
using (AssemblyInstaller inst = new AssemblyInstaller(typeof(MyServiceClass).Assembly, args))
{
IDictionary state = new Hashtable();
inst.UseNewContext = true;
//# Service Account Information
inst.Install(state);
inst.Commit(state);
}
安装它。我通过检测它是否启动成功来确定是否需要这样做。我预计在请求它启动和它实际设置它的 RunningOk 标志之间会有延迟,并且宁愿一个通用的、程序化的解决方案。 (How to install a windows service programmatically in C#?)http://dl.dropbox.com/u/152585/ServiceInstaller.cs 解决方案已经有将近 3 年的历史了,并且导入了 DLL,从我对 .NET 的了解来看,这似乎违背了它的安全意图。
因此,我想知道一种使用 .NET 的更简洁的方法(如果存在的话)?
【问题讨论】:
标签: c# .net windows-services windows-installer