What may cause IIS 7 to restart automatically

configurationiis-7

I'm trying to stop IIS 7 'Windows Process Activation Service' from within my application. It also stops a dependency – 'World Wide Web Publishing Service'. The dependency stops always but the main service doesn't. I think that it restarts automatically because I don't get any errors in my application. The question is what may cause IIS to restart automatically or prevent it from stopping?

p.s. I'm not doing any other things related to configuration, just stopping the service through the ServiceController object

Edit:

The startup type of the main service is manual and automatic for dependency. I also have such settings in service properties ->recovery->failure 1,2,3 run a program, iisreset.exe as a program to run. Anyway I didn't get any error in my application, but if it could restart due to some errors I'd like to know how to check that.

I should have mentioned also that it doesn't happen all the time, in most cases it stops, but sometimes it doesn't, I can't event get any pattern or relation to something

Best Answer

Windows Process Activation Service is not the main IIS service, World Wide Web Publishing Service is.

Pay no attention to the process activation service's state, and don't mess with it manually; it's just gonna do its own thing (which is why it's set to manual startup).