使用 Microsoft.Web.Administration.dll IIS 8.5 中的 WorkerProcess.GetRequests 方法时出错 [英] Got an error while using WorkerProcess.GetRequests method from Microsoft.Web.Administration.dll IIS 8.5
问题描述
我正在用 C#(.NET Framework 4.5)为 Microsoft Windows Server 2012 R2 Standard x64(IIS 8.5)编写一个 Windows 服务应用程序,并使用 Microsoft.Web.Administration.dll(来自 C:Windows 的 7.0.0.0System32inetsrv).
I'm writing a windows service application in C# (.NET Framework 4.5) for Microsoft Windows Server 2012 R2 Standard x64 (IIS 8.5) and using Microsoft.Web.Administration.dll (7.0.0.0 from C:WindowsSystem32inetsrv).
当我运行以下代码时:
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)"方法引发以下异常:
The Service starts with administrator privileges and "GetRequests(0)" method raises the following exception:
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 中得到相同的异常:
Got the same exception in PowerShell using the following code:
PS > [System.Reflection.Assembly]::LoadFrom("C:windowssystem32inetsrvMicrosoft.Web.Administration.dll" )
PS > $sm = new-object Microsoft.Web.Administration.ServerManager
PS > $sm.workerprocesses | foreach-object {$_.GetRequests(0)}
有人能给我建议吗?
推荐答案
我终于解决了我的问题.
I finally have solved my problem.
请按照以下步骤完成此问题:添加角色和功能向导 -> 服务器角色 -> Web 服务器 (IIS) -> Web 服务器 -> 运行状况和诊断 -> 请求监视器
Follow the steps below to complete this problem: Add Roles and Features Wizard -> Server Roles -> Web Server (IIS) -> Web Server -> Health and Diagnostics -> Request Monitor
这篇关于使用 Microsoft.Web.Administration.dll IIS 8.5 中的 WorkerProcess.GetRequests 方法时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!