C# .NET - Windows service cannot be started - Asked By Anandh Ramanujam on 09-Jun-11 06:30 AM


I have written a Windows service and installed perfectly.

But the service is not starting. In EventViewer, i found the exeption like this:

Service cannot be started. System.IndexOutOfRangeException: Index was outside the bounds of the array.
   at StagLoggerService.CommonFunctions.FindLocationFromIPAddress()
   at StagLoggerService.Service1.OnStart(String[] args)
   at System.ServiceProcess.ServiceBase.ServiceQueuedMainCallback(Object state)

Can anybody help me in this regard.


Jitendra Faye replied to Anandh Ramanujam on 09-Jun-11 07:01 AM

I'm not sure what could be causing this, but I did find some tips that might help you out (on the MSDN troubleshooting pages):

  • Make sure that the file is a valid .NET Framework assembly.
  • Check to make sure an assembly or module was not loaded twice with two different evidences.
  • If using the RegisterAssembly or UnregisterAssembly methods, check to make sure the assembly name is not longer than MAX_PATH characters.
  • If loading a satellite assembly, make sure the specified CultureInfo matches the file's CultureInfo.

Hope this will help you.

Anoop S replied to Anandh Ramanujam on 09-Jun-11 07:43 AM
This problem occurs if the Help and Support service is disabled. If the Help and Support Center is unnecessary in an environment, an administrator may disable the Help and Support service as a security best practice.Go to My Computer, Right click, click on manage
    * New window opens
    * In left look for Services, click to open
    * In right go down to Windows Installer
    * Double click
    * In drop down bar make the Service Automatic, close
    * In right pane of window click on Start to start this service.
    * Windows Installer is now started & will work when you need it to 
Anandh Ramanujam replied to Anoop S on 09-Jun-11 08:14 AM
Thanks for ur reply...

Still getting the same issue...