2013-02-11 104 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