2013-02-11 110 views
1

我有一个在Visual Studio中编写的Windows服务。我被要求更改服务名称,因此我进入了ServiceInstaller属性并更改了DisplayName和ServiceName属性。当我去开始通过Windows管理器中的服务,我收到以下错误:更改服务名称后窗口服务无法启动

The 'servicename' service on 'server name' started and then stopped. Some services stop automatically if they are in use by other services or programs.

日志文件说:

Service cannot be started. System.Security.SecurityException: The source was not found, but some or all event logs could not be searched. To create the source, you need permission to read all event logs to make sure that the new source name is unique.

任何帮助,将不胜感激。

谢谢!

回答

1

显然你没有注册一个事件源。您的事件源的名称很可能是从服务名称派生的,并且当您更改服务尝试使用未注册的新事件源时。

检入您的服务安装程序,您正在注册事件源 - 它必须在服务安装时注册,因为它需要提升管理员权限。有关示例,请参阅this SO question中的代码片段以了解如何注册该示例。

+0

你是对的。我从未注册过事件源。谢谢! – Anonymous 2013-02-11 16:57:00