我正在尝试在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) 当我在Visual Studio中停止调试时,如何自动停止开发Web服务器?
我们开发了一个使用Excel互操作库(Microsoft.Office.Interop.Excel)来读取一些Excel文件的应用程序.
当应用程序中出现问题时,将处理事件Application.ThreadException,因此将释放资源(Excel已关闭...).
问题是,当我们使用VS调试器时,如果我们停止执行(因为进程在异常或断点上中断,有很多原因导致我们这样做),资源不会被释放而Excel会停留打开.当然,下次启动应用程序时......由于文件上有锁,它会崩溃.
所以我正在寻找一种强制释放Excel对象的方法,即使在使用调试器停止时也是如此.
有什么建议吗?