6

我一直在尝试使用 installutil: 安装 Windows 服务installutil /u GSIS.FileMoverService.exe

我得到的输出是:

卸载程序集“C:\FMS\GSIS.FileMoverService.exe”。受影响的参数是:

logtoconsole = 日志文件 = C:\FMS\GSIS.FileMoverService.InstallLog

assemblypath = C:\FMS\GSIS.FileMoverService.exe 正在删除 EventLog 源文件移动器服务。

警告:源文件移动器服务未在本地计算机上注册。服务文件移动器服务正在从系统中删除...

卸载 System.ServiceProcess.ServiceInstaller 安装程序时发生异常。System.ComponentModel.Win32Exception:指定的服务不作为已安装的服务存在卸载时发生异常。

此异常将被忽略,卸载将继续。但是,卸载完成后应用程序可能不会完全卸载。

当我尝试卸载时,该服务已停止。它肯定已注册为服务。我已经重新启动,它仍然在服务小程序 (services.msc) 中可见。它还可以从服务小程序成功启动和停止,因此看起来它没有成功(或仅部分)安装。

我从 VS2010 命令提示符(单击以管理员身份运行)调用 installutil。

有任何想法吗?

4

2 回答 2

14

最后,我曾经sc delete GSIS.FileMoverService删除了该服务。这行得通。

于 2012-11-28T15:51:56.370 回答
3

所以我希望这与您扩展 System.Configuration.Install.Installer 的类有关。在您的类的构造函数中,您应该将 System.ServiceProcess.ServiceProcessInstaller 和 System.ServiceProcess.ServiceInstaller 添加到安装程序,例如:

public MyServiceInstaller(string displayName = null, string description = null, ServiceAccount account = ServiceAccount.LocalSystem, string username = "", string password = "", ServiceStartMode startType = ServiceStartMode.Automatic, bool delayedAutoStart = false, string[] servicesDependedOn = null)
{
    Installers.Add(new ServiceProcessInstaller
        {
            Account = ServiceAccount.LocalSystem,
            Username = username,
            Password = password
        });
Installers.Add(new ServiceInstaller
    {
        ServiceName = GetType().Name,
        StartType = startType,
        DisplayName = displayName ?? serviceName,
        Description = description ?? string.Empty,
        ServicesDependedOn = servicesDependedOn,
        DelayedAutoStart = delayedAutoStart
    });

}

ServiceInstaller 中的 ServiceName 需要与安装服务时分配给 ServiceInstaller 的 ServiceName 匹配。如果没有,那么您将收到此异常,因为它在尝试卸载之前找不到已安装的服务。

于 2013-12-06T19:01:49.400 回答