[英]WMI: The RPC server is unavailable. (Exception from HRESULT: 0x800706BA) throws when try to connect to remote machine
[英]The RPC server is unavailable. (Exception from HRESULT: 0x800706BA) when connecting to remote computer
我嘗試使用Winforms C#連接遠程計算機。
我的代碼:
private void Form1_Load(object sender, EventArgs e)
{
var connection = new ConnectionOptions();
connection.Username = "xx";
connection.Password = "xx";
var scope = new ManagementScope("\\\\111.111.111.22:6000\\root\\CIMV2", connection);
scope.Connect(); // Exception occurs here..
}
我在line scope.Connect();下面得到了Error
錯誤:
System.Management.dll中發生了類型為'System.Runtime.InteropServices.COMException'的未處理異常
附加信息:RPC服務器不可用。 (來自HRESULT的異常:0x800706BA)
任何幫助將不勝感激。
我很確定您沒有以管理員身份運行此應用程序。
多虧了UAC,您需要以管理員身份運行應用程序才能使其正常運行。
請參閱如何強制.NET應用程序以管理員身份運行? 了解如何將app.manifest添加到您的應用程序,以強制其以管理員身份運行。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.