我正在尝试使用以下语法远程回收aws应用程序池
using (DirectoryEntry appPoolEntry = new DirectoryEntry(
"IIS://" + appPoolModel.ServerName + "/W3SVC/AppPools/"+appPoolModel.AppPoolName))
{
appPoolEntry.Invoke("Recycle", null);
appPoolEntry.Close();
}
但我得到以下错误
System.Runtime.InteropServices.COMException(0x800706BA):RPC服务器不可用。
对于aws服务器,我使用的服务器名称如下
"ec2-[Server Public IP].compute-1.amazonaws.com"
答案 0 :(得分:0)
有几个原因。
错误地显示RPC服务器实际上没有运行的一个明显原因。
如果RPC服务器正在运行,则必须检查防火墙端口是否为RPC打开。 http://support.microsoft.com/kb/178517
执行代码的用户的上下文。支持您在user1的上下文中运行,并且它没有DirectoryEntry对象的权限,然后它可能会失败。
如果无法做到这一点,请尝试通过Remote Powershell进行此操作。