正在停止IIS应用程序池c#

正在停止IIS应用程序池c#,c#,iis,wmi,C#,Iis,Wmi,我正在尝试使用以下c#代码停止远程系统的IIS应用程序池: 如果我停止我的应用程序池,它会工作,但我会在服务器上遇到一系列错误: ----- The root\MicrosoftIISv2 namespace is marked with the RequiresEncryption flag. Access to this namespace might be denied if the script or application does not have the appropr

我正在尝试使用以下c#代码停止远程系统的IIS应用程序池:

如果我停止我的应用程序池,它会工作,但我会在服务器上遇到一系列错误:

 -----
 The root\MicrosoftIISv2 namespace is marked with the RequiresEncryption flag. 
 Access to this namespace might be denied if the script or application does not have the 
 appropriate authentication level. Change the authentication level to Pkt_Privacy 
 and run the script or application again.
 -----

 -----
 An unhandled exception occurred and the process was terminated.
 Application ID: DefaultDomain
 Process ID: 1640
 Exception: System.AppDomainUnloadedException
 Message: Attempted to access an unloaded AppDomain.
 StackTrace: 
 -----

 -----
 Application: w3wp.exe
 Framework Version: v4.0.30319
 Description: The process was terminated due to an unhandled exception.
 Exception Info: System.Configuration.ConfigurationErrorsException
 Stack:
 at System.Diagnostics.TraceUtils.GetRuntimeObject(System.String, System.Type, System.String)
 -----

 -----
 Faulting application name: w3wp.exe, version: 7.5.7601.17514, time stamp: 0x4ce7a5f8
 Faulting module name: KERNELBASE.dll, version: 6.1.7601.18409, time stamp: 0x53159a86
 Exception code: 0xe0434352
 Fault offset: 0x0000c42d
 Faulting process id: 0x668
 Faulting application start time: 0x01d194020cab3c08
 Faulting application path: C:\Windows\SysWOW64\inetsrv\w3wp.exe
 Faulting module path: C:\Windows\syswow64\KERNELBASE.dll
 Report Id: 57bb8e2a-fff5-11e5-8ddc-005056a330b1
 -----
我很确定我不应该收到这些错误,因为如果我手动(相对于编程)启动/停止应用程序池,我不会收到这些警告或错误

有人能帮我理解为什么我会犯这些错误吗。我想我正在设置数据包的隐私,这样警告对我来说就没有意义了

谢谢
Brad

我应该注意,这似乎只发生在Windows 2008 R2/IIS7上。相同的代码在Windows 2012 R2/IIS 8.1上运行良好。可能相关:。似乎ManagementPath类在处理未正确清理的内容时存在问题。我应该注意,这似乎只发生在Windows 2008 R2/IIS7上。相同的代码在Windows 2012 R2/IIS 8.1上运行良好。可能相关:。似乎ManagementPath类在处理未正确清理的内容时存在问题
 -----
 The root\MicrosoftIISv2 namespace is marked with the RequiresEncryption flag. 
 Access to this namespace might be denied if the script or application does not have the 
 appropriate authentication level. Change the authentication level to Pkt_Privacy 
 and run the script or application again.
 -----

 -----
 An unhandled exception occurred and the process was terminated.
 Application ID: DefaultDomain
 Process ID: 1640
 Exception: System.AppDomainUnloadedException
 Message: Attempted to access an unloaded AppDomain.
 StackTrace: 
 -----

 -----
 Application: w3wp.exe
 Framework Version: v4.0.30319
 Description: The process was terminated due to an unhandled exception.
 Exception Info: System.Configuration.ConfigurationErrorsException
 Stack:
 at System.Diagnostics.TraceUtils.GetRuntimeObject(System.String, System.Type, System.String)
 -----

 -----
 Faulting application name: w3wp.exe, version: 7.5.7601.17514, time stamp: 0x4ce7a5f8
 Faulting module name: KERNELBASE.dll, version: 6.1.7601.18409, time stamp: 0x53159a86
 Exception code: 0xe0434352
 Fault offset: 0x0000c42d
 Faulting process id: 0x668
 Faulting application start time: 0x01d194020cab3c08
 Faulting application path: C:\Windows\SysWOW64\inetsrv\w3wp.exe
 Faulting module path: C:\Windows\syswow64\KERNELBASE.dll
 Report Id: 57bb8e2a-fff5-11e5-8ddc-005056a330b1
 -----