Irakli Lekishvili
Irakli Lekishvili

Reputation: 34198

System.Security.SecurityException C# 2.0 windows service

I`m tring to install my windows service on Windows 7 x64

And getting this error

An exception occurred during the Rollback phase of the System.Diagnostics.EventLogInstaller installer.
System.Security.SecurityException: The source was not found, but some or all event logs could not be searched.  Inaccessible logs: Security.
An exception occurred during the Rollback phase of the installation. This exception will be ignored and the rollback will continue. However, the machine might not fully revert to its initial state after the rollback is complete.

this is my MyWindowsServiceInstaller code:

var processInstaller = new ServiceProcessInstaller();
            var serviceInstaller = new ServiceInstaller();
            processInstaller.Account = ServiceAccount.LocalSystem;
            serviceInstaller.DisplayName = "My Service";
            serviceInstaller.StartType = ServiceStartMode.Manual;
            serviceInstaller.ServiceName = "My Service";
            this.Installers.Add(processInstaller);
            this.Installers.Add(serviceInstaller);

i have set my application name to start up project

Here is bat file

@ECHO OFF

REM The following directory is for .NET 2.0
set DOTNETFX2=%SystemRoot%\Microsoft.NET\Framework\v2.0.50727
set PATH=%PATH%;%DOTNETFX2%

echo Installing MyService...
echo ---------------------------------------------------
InstallUtil /i ConsoleApplication5.exe
echo ---------------------------------------------------
echo Done.
pause

This service is not only my computer if i will solve this problem it would be solved for any other computers?

Thanks

Upvotes: 2

Views: 11840

Answers (2)

Muhammad Rizwan
Muhammad Rizwan

Reputation: 348

You may also overcome such issue by starting "Visual Studio Command Prompt" as "Run as administrator" option. Now install your assembly with installutil.exe command

x:\Windows\System32>installutil.exe YourService.exe

(Where YourService.exe is the compiled exe file of your service project)

Directions: To open the command prompt, click on "All Programs" -> "Microsoft Visual Studio (20xx)" -> "Visual Studio Tools (20xx)" -> "Visual Studio Command Prompt" (where 20xx is the respective version you are using like 2008, 2010 etc.).

Upvotes: 2

Satheesh
Satheesh

Reputation: 902

U can try installing in this way. Open cmd as administator and locate to .Net Framework path in your system

Eg: "C:\Windows\Microsoft.Net\Framework\v4.0.30319\"

Then with the help of installutil.exe you can install the service.

Eg: C:\Windows\Microsoft.Net\Framework\v4.0.30319\installutil.exe "Your service exe path"

Upvotes: 8

Related Questions