无法在Windows服务中承载IIS Express

时间:2012-05-02 17:05:38

标签: c# windows-services iis-express

我遵循了以下SO文章 - How to run IIS Express as a process started via a Windows Service

我使用以下代码在我的机器上安装了Windows服务:

private Process _process;

protected override void OnStart(string[] args)
{
    var processStartInfo = new ProcessStartInfo
    {
        FileName = @"C:\Program Files (x86)\IIS Express\iisexpress.exe",
    };

    _process = new Process
    {
        StartInfo = processStartInfo,
        EnableRaisingEvents = true
    };

    _process.Start();
}

protected override void OnStop()
{
    _process.Kill();
}

但是,当我尝试启动该服务时,经过长时间尝试启动该服务后,它将失败。当我检查事件日志时,我收到以下IIS Express错误:

The worker process for app pool 'Clr4IntegratedAppPool', PID='8596', failed to initialize the http.sys communication when asked to start processing http requests and therefore will be considered ill by W3SVC and terminated.  The data field contains the error number.

The worker process failed to initialize correctly and therefore could not be started.  The data is the error.

1 个答案:

答案 0 :(得分:0)

我认为默认情况下LocalSystem没有网络访问权限。尝试使用NetworkService用户。