I've followed the following SO article - How to run IIS Express as a process started via a Windows Service
I've installed the Windows Service on my machine using the following code:
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();
}
However when I attempt to start the service, after a long attempt to start the service it fails. When I check the Event Log, I get the following IIS Express errors:
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.