title: Starting and stopping IIS Express programmatically
body: <p>I am trying to build a small application in C# which should start/stop an IIS Express worker process. For this purpose I want to use the official "IIS Express API" which is documented on MSDN: <a href="http://msdn.microsoft.com/en-us/library/gg418415.aspx" rel="noreferrer">http://msdn.microsoft.com/en-us/library/gg418415.aspx</a></p>
  
  <p>As far as I understand, the API is based (only) on COM interfaces. To use this COM interfaces I've added a reference to the COM library in VS2010 via Add Reference -> COM -> "IIS Installed Versions Manager Interface":</p>
  
  <p><img src="https://i.stack.imgur.com/x1el0.png" alt=""></p>
  
  <p>So far so good, but what's next? There is an <code>IIISExprProcessUtility</code> interface available which includes the the two "methods" to start/stop an IIS process. Do I have to write a class which implements this interface?</p>
  
  <pre><code>public class test : IISVersionManagerLibrary.IIISExprProcessUtility
  {
      public string ConstructCommandLine(string bstrSite, string bstrApplication, string bstrApplicationPool, string bstrConfigPath)
      {
          throw new NotImplementedException();
      }
  
      public uint GetRunningProcessForSite(string bstrSite, string bstrApplication, string bstrApplicationPool, string bstrConfigPath)
      {
          throw new NotImplementedException();
      }
  
      public void StopProcess(uint dwPid)
      {
          throw new NotImplementedException();
      }
  } 
  </code></pre>
  
  <p>As you can see, I'm not a professional developer. Can someone point me in the right direction.
  Any help is greatly appreciated.</p>
  
  <p><strong>Update 1:</strong>
  According to the suggestions I've tried the following code which unfortunately doesn't work:</p>
  
  <p><img src="https://i.stack.imgur.com/x70Ck.png" alt="alt text">
  Ok, it can be instantiated but I cannot see how to use this object...</p>
  
  <p><img src="https://i.stack.imgur.com/PEeMZ.png" alt="alt text"></p>
  
  <p><img src="https://i.stack.imgur.com/Qlpqj.png" alt="alt text"></p>
  
  <pre><code>IISVersionManagerLibrary.IIISExpressProcessUtility test3 = (IISVersionManagerLibrary.IIISExpressProcessUtility) Activator.CreateInstance(Type.GetTypeFromCLSID(new Guid("5A081F08-E4FA-45CC-A8EA-5C8A7B51727C")));
  
  Exception: Retrieving the COM class factory for component with CLSID {5A081F08-E4FA-45CC-A8EA-5C8A7B51727C} failed due to the following error: 80040154 Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG)).
  </code></pre>