Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Got an error while using WorkerProcess.GetRequests method from Microsoft.Web.Administration.dll IIS 8.5

Tags:

c#

iis

.net-4.5

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:\Windows\System32\inetsrv).

When I run the following code:

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;
             }
        }
    }
}

The Service starts with administrator privileges and "GetRequests(0)" method raises the following exception:

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

StackTrace:

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

Got the same exception in PowerShell using the following code:

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)}

Can someone advice me?

like image 267
Andrii Motrych Avatar asked Oct 04 '13 12:10

Andrii Motrych


1 Answers

I finally have solved my problem.

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

like image 116
Andrii Motrych Avatar answered Oct 15 '22 15:10

Andrii Motrych