Iniciar y detener IIS Express mediante programación
Estoy tratando de construir una pequeña aplicación en C # que debería iniciar / detener un proceso de trabajo de IIS Express. Para este propósito, quiero usar la "API IIS Express" oficial que está documentada en MSDN:http://msdn.microsoft.com/en-us/library/gg418415.aspx
Según tengo entendido, la API se basa (solo) en interfaces COM. Para usar estas interfaces COM, agregué una referencia a la biblioteca COM en VS2010 mediante Agregar referencia -> COM -> "Interfaz del Administrador de versiones instaladas de IIS":
Hasta ahora todo bien, pero ¿qué sigue? Hay unIIISExprProcessUtility
interfaz disponible que incluye los dos "métodos" para iniciar / detener un proceso IIS. ¿Tengo que escribir una clase que implemente esta interfaz?
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();
}
}
Como puede ver, no soy un desarrollador profesional. Alguien me puede apuntar en la dirección correcta. Cualquier ayuda es muy apreciada.
Actualización 1: De acuerdo con las sugerencias, probé el siguiente código que desafortunadamente no funciona:
Ok, se puede instanciar pero no puedo ver cómo usar este objeto ...
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)).