The RPC server is unavailable. (Exception from HRESULT: 0x800706BA) when connecting to remote computer

不想你离开。 提交于 2019-12-24 15:15:20

问题


I try to connect remote computer by using 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();

Error:

An unhandled exception of type 'System.Runtime.InteropServices.COMException' occurred in System.Management.dll

Additional information: The RPC server is unavailable. (Exception from HRESULT: 0x800706BA)

Any help will be appreciated.


回答1:


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.

See How do I force my .NET application to run as administrator? to read how to add a app.manifest to your application, forcing it to run as administrator.



来源:https://stackoverflow.com/questions/23334962/the-rpc-server-is-unavailable-exception-from-hresult-0x800706ba-when-connect

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!