我正在尝试通过WCF服务启动Windows服务。但是,当从客户端调用服务方法时,它会抛出错误String increment(String num,int incrementBy) //incrementBy is an integer by which you want to increment
{
int numInt=Integer.parseInt(num);
numInt+=incrementBy;
if (numInt>9999)
return String.valueOf(numInt-9999);
return String.valueOf(numInt);
}
。下面是示例代码:
请提出您的解决方案
WCF代码:
Access Denied
客户代码:
public string StartService()
{
ServiceController oService = new ServiceController("My Windows Service");
TimeSpan oTime = TimeSpan.FromMilliseconds(10000);
if (oService.Status == ServiceControllerStatus.Stopped)
{
oService.Start();
}
oService.WaitForStatus(ServiceControllerStatus.Running, oTime);
}