c# - 使用 Microsoft.Web.Administration.dll IIS 8.5 中的 WorkerProcess.GetRequests 方法时出错

标签 c# iis .net-4.5

我正在用 C# (.NET Framework 4.5) 为 Microsoft Windows Server 2012 R2 Standard x64 (IIS 8.5) 编写 Windows 服务应用程序并使用 Microsoft.Web.Administration.dll(7.0.0.0 来自 C:\Windows\System32\inetsrv).

当我运行以下代码时:

using(var srvmngr = new Microsoft.Web.Administration.ServerManager())
{
    foreach(var pl in srvmngr.ApplicationPools)
    {
         foreach (var w3wp in pl.WorkerProcesses)
         {
             foreach (var request in w3wp.GetRequests(0))
             {
                 var success = true;
             }
        }
    }
}

服务以管理员权限启动,“GetRequests(0)”方法引发以下异常:

System.NotImplementedException - {"The method or operation is not implemented."}

堆栈跟踪:

at Microsoft.Web.Administration.Interop.IAppHostMethodInstance.Execute()
at Microsoft.Web.Administration.ConfigurationMethodInstance.Execute()
at Microsoft.Web.Administration.WorkerProcess.GetRequests(Int32 timeElapsedFilter)

使用以下代码在 PowerShell 中得到相同的异常:

PS > [System.Reflection.Assembly]::LoadFrom("C:\windows\system32\inetsrv\Microsoft.We‌​‌​b.Administration.dll" )
PS > $sm = new-object Microsoft.Web.Administration.ServerManager
PS > $sm.workerprocesses | foreach-object {$_.GetRequests(0)}

有人可以给我建议吗?

最佳答案

我终于解决了我的问题。

按照以下步骤完成本题: 添加角色和功能向导 -> 服务器角色 -> Web 服务器 (IIS) -> Web 服务器 -> 健康和诊断 -> 请求监视器

关于c# - 使用 Microsoft.Web.Administration.dll IIS 8.5 中的 WorkerProcess.GetRequests 方法时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19181418/

相关文章:

c# - 将 Kestrel 暴露于外界的风险

c# - .NET 4.0 替代 .NET 4.5 命名空间

c# - 如果由于程序崩溃而未关闭,打开的文件流会发生什么情况?

c# - 如何在 <%# Eval "or")%> 内联语句中使用 ('column' 条件?

c# - 多集线器一连,防止神级

c# - 方法声明中的方括号如何适应 c#?

windows - 64 位操作系统 (windows) 上的 32 位应用程序

c# - 对象到 System.String 的隐式转换

c# - "The file .master does not exist"

c# Resharper 'No Tests Found in Project'/'Inconclusive: Test wasn' t 运行'