Hi,
I have a problem on C# windows service, its showing an error - The array bounds are invalid
Note - If my dv.Count value is less than or equal to 1000 then its not showing error and works fine, but id dv.Count is more then 1000 then it generate the error....
Here is my code
string[] arg = new string[dv.Count];
for (int xx = 0; xx < dv.Count; xx++)
{
arg[xx] = dv[xx]["id"].ToString() + "," + dv[xx]["item"].ToString()
}
ServiceController sc = new ServiceController("Service1");
if (sc != null)
{
if (sc.Status.ToString().ToLower() == "stopped")
{
sc.Start(arg); // Error Occurred Here
}
}
Here is the full error details.
System.InvalidOperationException: Cannot start service xxxxx on computer '.'. ---> System.ComponentModel.Win32Exception: The array bounds are invalid
--- End of inner exception stack trace ---
at System.ServiceProcess.ServiceController.Start(String[] args)
at xxxxxx.Service1.Generate(Object sender, ElapsedEventArgs e)
Can someone please help on this...?
Loading

VulpesPosted Nov 12, 2013, 6:47 PM
I wondered at first whether the 1001st string might be null which definitely isn't allowed but that doesn't appear to be possible as it must contain at least a comma and you'd get a different exception in any case.