我在asp.net 中 用如下的代码 重启 iis 进程 ServiceController sc = new ServiceController("iisadmin");
sc.Start();HttpRuntime.UnloadAppDomain();
Process p = new Process();
结果报错 服务的范例已在运行中
是怎么回事
sc.Start();HttpRuntime.UnloadAppDomain();
Process p = new Process();
结果报错 服务的范例已在运行中
是怎么回事
{
sc.Start();
}
else
{
sc.Stop();
while (sc.Status != ServiceControllerStatus.Stopped)
{
Thread.Sleep(1000);
}
sc.Start();
}
if (sc.Status == ServiceControllerStatus.Running)
{
sc.Stop();
sc.WaitForStatus(ServiceControllerStatus.Stopped); //等待服务停止
if (sc.Status == ServiceControllerStatus.Stopped)
{
sc.Start();
}
}
else
{
sc.Start();
}
if (sc.Status == ServiceControllerStatus.Running)
{
sc.Stop();
sc.WaitForStatus(ServiceControllerStatus.Stopped); //等待服务停止
if (sc.Status == ServiceControllerStatus.Stopped)
{
sc.Start();
}
}
else
{
sc.Start();
} HttpRuntime.UnloadAppDomain();
Process p = new Process();
或是放到
控制台程序中这样iis 不工作了,再次浏览网页就打不开了,得先停止iis ,再启动iis 才可以浏览,这是怎么回事