C# windows services 使用IDictionary 问题??
在安装服务的时候我想用代码操作??在网上找了段代码、如下:
/// <summary>
/// 安装服务
/// </summary>
/// <param name="stateSaver">集合</param>
/// <param name="filepath">Windows服务文件</param>
public static void InstallService(IDictionary stateSaver, string filepath)
{
try
{
AssemblyInstaller myAssemblyInstaller = new AssemblyInstaller();
myAssemblyInstaller.UseNewContext = true;
myAssemblyInstaller.Path = filepath;
myAssemblyInstaller.Install(stateSaver);
myAssemblyInstaller.Commit(stateSaver);
myAssemblyInstaller.Dispose();
}
catch (Exception ex)
{
throw new Exception(ex.Message, ex);
}
}