相关疑难解决方法(0)

以编程方式启动和停止IIS Express

我正在尝试在C#中构建一个小应用程序,它应该启动/停止IIS Express工作进程.为此,我想使用MSDN上记录的官方"IIS Express API":http://msdn.microsoft.com/en-us/library/gg418415.aspx

据我所知,API仅(仅)基于COM接口.为了使用这个COM接口,我通过Add Reference - > COM - >"IIS Installed Versions Manager Interface"在VS2010中添加了对COM库的引用:

到目前为止一切都很好,但下一步是什么?有一个IIISExprProcessUtility可用的接口,包括启动/停止IIS进程的两个"方法".我是否必须编写一个实现此接口的类?

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();
    }
} 
Run Code Online (Sandbox Code Playgroud)

如您所见,我不是一名专业开发人员.有人能指出我正确的方向.任何帮助是极大的赞赏.

更新1: 根据建议,我尝试了下面的代码,但遗憾的是它不起作用:

替代文字 好的,它可以实例化但我看不到如何使用这个对象...

替代文字

替代文字

IISVersionManagerLibrary.IIISExpressProcessUtility test3 = (IISVersionManagerLibrary.IIISExpressProcessUtility) Activator.CreateInstance(Type.GetTypeFromCLSID(new Guid("5A081F08-E4FA-45CC-A8EA-5C8A7B51727C")));

Exception: Retrieving the …
Run Code Online (Sandbox Code Playgroud)

c# com iis com-interop iis-express

56
推荐指数
3
解决办法
3万
查看次数

标签 统计

c# ×1

com ×1

com-interop ×1

iis ×1

iis-express ×1