Uttam Kumar
Uttam Kumar

Reputation: 31

When I try to start my Windows service, I get error number 1053

I am trying to pass a parameter to a Windows service, when I install the service using the command prompt in given manner shown below

d:\mypath>installutil -i service.exe -parameter

Before installing in program.cs file I have written in the following manner

static void Main(string[] args)
        {
            **string path = args[0];**              
            ServiceBase[] ServicesToRun;
            ServicesToRun = new ServiceBase[] 
            { 
                **new VibrantEmail(path)** 
            };
            ServiceBase.Run(ServicesToRun);
        }

and in service.cs page I have written this

**public VibrantEmail(string path)**
        {
            **data = path**
            InitializeComponent();
        }

The thing is like when I use static void Main(string[] args) in program.cs page then only I get this error, number 1053. Can anyone help me out?

Upvotes: 1

Views: 106

Answers (1)

Tomek
Tomek

Reputation: 3279

You can't provide arguments at installation step. Installutil expects only assembly of which installer component will be executed. You will have to use Environment.GetCommandLineArgs to retrieve arguments in your code, then install service without providing parameters and modify its execution path based on this instructions.

Upvotes: 0

Related Questions