1

i have a server in which i published a asp.net web site. i want to create a console application which show how many worker processes are in the IIS. please any help

Ahmar
  • 3,717
  • 2
  • 24
  • 42
vijay joshi
  • 38
  • 1
  • 10

1 Answers1

1

You can add this reference in project Microsoft.Web.Administration assembly which can be installed using this nuget package or by adding a reference to this dll %WinDir%\System32\InetSrv\Microsoft.Web.Administration.dll

using (ServerManager manager = new ServerManager())
{
        var requests = manager.ApplicationPools
                                .SelectMany(pool => pool.WorkerProcesses).Count();
        Console.WriteLine(requests);
}
Ahmar
  • 3,717
  • 2
  • 24
  • 42
  • i used this code but it throw below error . Additional information: Retrieving the COM class factory for component with CLSID {2B72133B-3F5B-4602-8952-803546CE3344} failed due to the following error: 80040154 Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG)). – vijay joshi Dec 29 '16 at 13:08
  • Try to run with Administrator. I test this on VS 2015. – Ahmar Dec 29 '16 at 14:21
  • Did you have IIS installed on your system where you test it ? – Ahmar Dec 30 '16 at 04:46
  • no i don't, IIS is installed on another machine(window server 2016). – vijay joshi Dec 30 '16 at 09:49
  • Run this code on where you installed IIS. It will work there. You except output on your system while the output source IIS not present. That's why it give error to you. – Ahmar Dec 30 '16 at 09:54