4
protected void btnRecycle_Click(object sender, EventArgs e)
{
    ServerManager mgr = new ServerManager();
    System.Collections.IEnumerator ie = mgr.ApplicationPools.GetEnumerator();

    while (ie.MoveNext())
    {
                    ddlApplicationPool.Items.Add(((Microsoft.Web.Administration.ApplicationPool)(ie.Current)).Name);
    }

}

Error:

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)).

Riyaju
  • 67
  • 1
  • 8

1 Answers1

7

This exception gets thrown if IIS is not installed in Windows. You can use that exception as a dependency checker.

To install IIS, do the following:

Windows Start Menu > Control Panel > Programs and Features > Turn Windows Features on or off > check the top node in the "Internet Information Services" tree

enter image description here

EDIT:

A better way is just to check for the service this way.

System.ServiceProcess.ServiceController sc1 = new System.ServiceProcess.ServiceController("World Wide Web Publishing Service");
JustBeingHelpful
  • 18,332
  • 38
  • 160
  • 245