[英]The RPC server is unavailable. (Exception from HRESULT: 0x800706BA) when connecting to remote computer
I try to connect remote computer by using winforms c#. 我尝试使用Winforms C#连接远程计算机。
My Code: 我的代码:
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..
}
I get below Error in line scope.Connect(); 我在line scope.Connect();下面得到了Error
Error: 错误:
An unhandled exception of type 'System.Runtime.InteropServices.COMException' occurred in System.Management.dll System.Management.dll中发生了类型为'System.Runtime.InteropServices.COMException'的未处理异常
Additional information: The RPC server is unavailable. 附加信息:RPC服务器不可用。 (Exception from HRESULT: 0x800706BA) (来自HRESULT的异常:0x800706BA)
Any help will be appreciated. 任何帮助将不胜感激。
I am pretty sure you did not run this application as administrator. 我很确定您没有以管理员身份运行此应用程序。
Thanks to UAC you need to run your application as administrator to get this to work. 多亏了UAC,您需要以管理员身份运行应用程序才能使其正常运行。
See How do I force my .NET application to run as administrator? 请参阅如何强制.NET应用程序以管理员身份运行? to read how to add a app.manifest to your application, forcing it to run as administrator. 了解如何将app.manifest添加到您的应用程序,以强制其以管理员身份运行。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.