安装服务时出错:指定的服务已存在 [英] Error installing service: The specified service already exists

查看:1076
本文介绍了安装服务时出错:指定的服务已存在的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在Visual C#Express(无WindowsService模板)中工作,并尝试编写我的第一个服务.我已经解决了几个问题,但是我对此有些困惑.我在尝试在项目的Release文件夹中运行InstallUtil时收到以下错误:

I'm working in Visual C# Express (no WindowsService template) and attempted to write my first service. I've gotten through a few issues already, but I'm a bit stumped on this one. I'm receiving the following error trying to run the InstallUtil in the Release folder of my project:

在安装阶段发生了异常.
System.ComponentModel.Win32Exception:指定的服务已经存在

An exception occurred during the Install phase.
System.ComponentModel.Win32Exception: The specified service already exists

在这里,我认为值得一提的是,在此之前,我已经运行了很多次安装,尽管这些尝试都没有成功,

我也已经搜索并找到了对类似问题的其他答复,但是在大多数情况下,这似乎是由剩余的材料"引起的.在注册表中.我尝试在注册表中搜索"MediaManager"; (该服务称为MediaManagerFileBackupService,而exe文件为MediaManager.Manager.Service.exe),但没有任何提示.

我的安装程序代码非常简单;我有一个从ServiceInstaller派生的类,其RunInstallerAttribute设置为true,在构造函数中具有以下代码: br> ServiceProcessInstaller spiFileBackup = new ServiceProcessInstaller();
spiFileBackup.Account = ServiceAccount.LocalSystem;
>
的ServiceInstaller siFileBackup = new ServiceInstaller();
siFileBackup.DisplayName = strSource;

Installers.Add(spiFileBackup);
Installers.Add(siFileBackup);


下面,我已经复制了安装日志.我可能会误解日志输出,但是在我看来,InstallUtil尝试至少两次单独安装该服务(如果不是更多次).我已经加粗并用斜体显示了试图多次安装的部分(在控制台日志中,在加粗/斜体部分之后,我直接收到指定的服务已存在"错误).


InstallUtil.InstallLog

I think it is probably worth noting here that I have run the install many times previous to this, though none of these attempts have been successful, for wholly separate reasons.

I have also searched and found other replies to similar issues, but in most cases it seems this is caused by leftover "stuff" in the registry. I tried searching my registry for "MediaManager" (the service is called MediaManagerFileBackupService and the exe file is MediaManager.Manager.Service.exe) and came up with nothing.

My installer code is very simple; I have a class derived from ServiceInstaller with the RunInstallerAttribute set to true, with the following code in the constructor:

            string strSource = "MediaManagerFileBackupService";

            ServiceName = strSource;

            ServiceProcessInstaller spiFileBackup = new ServiceProcessInstaller();
            spiFileBackup.Account = ServiceAccount.LocalSystem;
            spiFileBackup.Username = null;
            spiFileBackup.Password = null;
            spiFileBackup.Parent = this;

            ServiceInstaller siFileBackup = new ServiceInstaller();
            siFileBackup.DisplayName = strSource;
            siFileBackup.ServiceName = strSource;
            siFileBackup.StartType = ServiceStartMode.Manual;
            siFileBackup.Parent = this;

            Installers.Add(spiFileBackup);
            Installers.Add(siFileBackup);


Below I've copied the logs for the install. I may be misunderstanding the log output, but it looks to me like the InstallUtil is trying install the service at least two separate times, if not more. I've bolded and italicized the section that looks like it's trying to install more than once (in the console log, it is directly after the bold/ italicized section that I get the "The specified service already exists" error).


InstallUtil.InstallLog

运行事务处理的安装.

开始安装的安装阶段.
请参阅C:\ Users \ Evan \ Documents \ Visual Studio 2008 \ Projects \ MediaManager \ MediaManager.Manager.Service \ bin \ Release \ MediaManager.Manager.Service.exe程序集进度的日志文件.
该文件位于C :\ Users \ Evan \ Documents \ Visual Studio 2008 \ Projects \ MediaManager \ MediaManager.Manager.Service \ bin \ Release \ MediaManager.Manager.Service.InstallLog.

在安装阶段发生异常.
System.ComponentModel.Win32Exception:指定的服务已经存在

安装的回滚阶段正在开始.
请参阅日志文件的内容以获取C:\ Users \ Evan \ Documents \ Visual Studio 2008 \ Projects \ MediaManager \ MediaManager.Manager.Service \ bin \ Release \ MediaManager.Manager.Service.exe程序集的进度.
文件位于C:\ Users \ Evan \ Documents \ Visual Studio 2008 \ Projects \ MediaManager \ MediaManager.Manager.Service \ bin \ Release \ MediaManager.Manager.Service.InstallLog.

回滚阶段已成功完成.

事务处理安装已完成. .
Running a transacted installation.

Beginning the Install phase of the installation.
See the contents of the log file for the C:\Users\Evan\Documents\Visual Studio 2008\Projects\MediaManager\MediaManager.Manager.Service\bin\Release\MediaManager.Manager.Service.exe assembly's progress.
The file is located at C:\Users\Evan\Documents\Visual Studio 2008\Projects\MediaManager\MediaManager.Manager.Service\bin\Release\MediaManager.Manager.Service.InstallLog.

An exception occurred during the Install phase.
System.ComponentModel.Win32Exception: The specified service already exists

The Rollback phase of the installation is beginning.
See the contents of the log file for the C:\Users\Evan\Documents\Visual Studio 2008\Projects\MediaManager\MediaManager.Manager.Service\bin\Release\MediaManager.Manager.Service.exe assembly's progress.
The file is located at C:\Users\Evan\Documents\Visual Studio 2008\Projects\MediaManager\MediaManager.Manager.Service\bin\Release\MediaManager.Manager.Service.InstallLog.

The Rollback phase completed successfully.

The transacted install has completed.


MediaManager.Manager.Service.InstallLog

安装程序集'C:\ Users \ Evan \ Documents \ Visual Studio 2008 \ Projects \ MediaManager \ MediaManager.Manager.Service \ bin \ Release \ MediaManager.Manager.Service.exe'.
受影响的参数为:
logtoconsole =
Assemblypath = C:\ Users \ Evan \ Documents \ Visual Studio 2008 \ Projects \ MediaManager \ MediaManager.Manager.Service \ bin \ Release \ MediaManager.Manager.Service.exe
日志文件= C:\ Users \ Evan \ Documents \ Visual Studio 2008 \ Projects \ MediaManager \ MediaManager.Manager.Service \ bin \释放\ MediaManager.Manager.Service.InstallLog
安装服务MediaManagerFileBackupService ...
在日志应用程序中创建EventLog源MediaManagerFileBackupService ...
安装服务MediaManagerFileBackupService ...
服务MediaManagerFileBackupService已成功安装.
在日志应用程序中创建EventLog源MediaManagerFileBackupService ...
在日志应用程序中创建服务MediaManagerFileBackupService ...
在日志应用程序中创建EventLog源MediaManagerFileBackupService ...

回滚程序集'C:\ Users \ Evan \ Documents \ Visual Studio 2008 \ Projects \ MediaManager \ MediaManager.Manager.Service \ bin \ Release \ MediaManager.Manager.Service.exe'.
受影响的参数是:
logtoconsole =
程序集路径= C:\ Users \ Evan \ Documents \ Visual Studio 2008 \ Projects \ MediaManager \ MediaManager.Manager.Service \ bin \ Release \ MediaManager.Manager.Service.exe
日志文件= C:\用户\ Evan \ Documents \ Visual Studio 2008 \ Projects \ MediaManager \ MediaMan ager.Manager.Service \ bin \ Release \ MediaManager.Manager.Service.InstallLog
将事件日志恢复到源MediaManagerFileBackupService的先前状态.
事件事件日志恢复到源MediaManagerFileBackupService的先前状态.已从系统中删除...
服务MediaManagerFileBackupService已成功从系统中删除.
将事件日志恢复为源MediaManagerFileBackupService的先前状态.

Installing assembly 'C:\Users\Evan\Documents\Visual Studio 2008\Projects\MediaManager\MediaManager.Manager.Service\bin\Release\MediaManager.Manager.Service.exe'.
Affected parameters are:
   logtoconsole =
   assemblypath = C:\Users\Evan\Documents\Visual Studio 2008\Projects\MediaManager\MediaManager.Manager.Service\bin\Release\MediaManager.Manager.Service.exe
   logfile = C:\Users\Evan\Documents\Visual Studio 2008\Projects\MediaManager\MediaManager.Manager.Service\bin\Release\MediaManager.Manager.Service.InstallLog
Installing service MediaManagerFileBackupService...
Creating EventLog source MediaManagerFileBackupService in log Application...
Installing service MediaManagerFileBackupService...
Service MediaManagerFileBackupService has been successfully installed.
Creating EventLog source MediaManagerFileBackupService in log Application...
Installing service MediaManagerFileBackupService...
Creating EventLog source MediaManagerFileBackupService in log Application...

Rolling back assembly 'C:\Users\Evan\Documents\Visual Studio 2008\Projects\MediaManager\MediaManager.Manager.Service\bin\Release\MediaManager.Manager.Service.exe'.
Affected parameters are:
   logtoconsole =
   assemblypath = C:\Users\Evan\Documents\Visual Studio 2008\Projects\MediaManager\MediaManager.Manager.Service\bin\Release\MediaManager.Manager.Service.exe
   logfile = C:\Users\Evan\Documents\Visual Studio 2008\Projects\MediaManager\MediaManager.Manager.Service\bin\Release\MediaManager.Manager.Service.InstallLog
Restoring event log to previous state for source MediaManagerFileBackupService.
Restoring event log to previous state for source MediaManagerFileBackupService.
Service MediaManagerFileBackupService is being removed from the system...
Service MediaManagerFileBackupService was successfully removed from the system.
Restoring event log to previous state for source MediaManagerFileBackupService.

在此问题上的任何帮助将大为有用赞赏.提前谢谢.

Any help on this issue would be greatly appreciated. Thanks in advance.

推荐答案

在命令提示符下,尝试

sc删除YourServiceName

正常工作,您无法弄清楚注册表如何崩溃,请尝试更改服务名称.
At the command prompt, try

  sc delete YourServiceName

If that doesn't work and you can't figure out how your registry got borked, try changing the service name.


这篇关于安装服务时出错:指定的服务已存在的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆