Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

error while installing window service System.Security.SecurityException

Tags:

I created a window service and to install it I created its deployment project and installed that. After installing I stared it. It successfully started.

Next day I made some modification, and rebuild and reinstalled but now its not installing.

Then I thought its issue with installer, lets create a custom installer for service so that anytime I can update my code.

I created it like this incase if anyone need this for future.

public class MyInstaller : Installer     {         ServiceProcessInstaller spi;         ServiceInstaller si;         public MyInstaller()         {                         spi = new ServiceProcessInstaller();             spi.Account = ServiceAccount.LocalSystem;              si = new ServiceInstaller();             si.StartType = ServiceStartMode.Manual;             si.ServiceName = "MyService";             si.DisplayName = "My Service";             si.Description = "service installed from command line";              this.Installers.Add(spi);             this.Installers.Add(si);          } } 

I called it from main method by check the parameter args.

                            case "-i":                             case "-install":                                 ti = new TransactedInstaller();                                 mi = new MyInstaller();                                 ti.Installers.Add(mi);                                 string logPath = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location) + "\\install.log";                                 ctx = new InstallContext(logPath, cmdline);                                 ti.Context = ctx; //.Context ( ctx );                                 ti.Install(new Hashtable());                                 break; 

Now when I am trying to install. I recevied error System.Security.SecurityException: The source was not found, but some or all event logs could not be searched. Inaccessible logs: Security.

I google it, and come to know service will try to access application log while installing and write log there.

I am not writing any event log. I have my log4net for logging. But still its default behaviour.

How to overcome this issue now? Its not getting installed even I have all permissions.

Thanks

like image 290
sunder Avatar asked May 03 '12 06:05

sunder


1 Answers

I have found that at times you may need to "Run as Administrator". If you are installing from a command prompt you may need to start that up with "Run as Administrator".

like image 131
Eben Roux Avatar answered Oct 08 '22 21:10

Eben Roux