从Linux获取在远程Windows机器上运行的进程c#

时间:2015-11-26 09:57:35

标签: c# exception mono notimplementedexception

我已经尝试了一段时间并且谷歌搜索了很多但是找不到合适的支持。 在Mon上运行基于.Net的项目,并尝试获取在远程Windows机器上运行的进程ID。而且不能继续......

ConnectionOptions connectoptions = new ConnectionOptions();     
string ipAddress = "XX.XX.X.XXX";

ManagementScope scope = new ManagementScope(@"\\" + ipAddress + @"\root\cimv2", connectoptions);
scope.Options = connectoptions; 
var query = new SelectQuery("select * from Win32_process where name = '" +    ProcessName + "'");
List<int> EPids = new List<int>();

using (ManagementObjectSearcher searcher = new ManagementObjectSearcher(scope, query))
{
    foreach (ManagementObject EProcess in searcher.Get()) 
    {
       var pId = Convert.ToInt32(EngineProcess["ProcessId"]);                                
                EnginePids.Add(pId);
                Console.WriteLine(pId);                                                  
    }
}           
return EPids.ToArray();

  

scope.Options = connectoptions

我发现了一个System.NotImplemented异常。想知道MONO是否真的支持这个?

1 个答案:

答案 0 :(得分:0)

ManagementScope类中没有实现任何内容:

System.Management/System.Management/ManagementScope.cs

public ConnectionOptions Options {
   [MonoTODO]
   get {
      throw new NotImplementedException ();
   }
   [MonoTODO]
   set {
      throw new NotImplementedException ();
   }
}

参考:https://github.com/mono/mono/blob/b7a308f660de8174b64697a422abfc7315d07b8c/mcs/class/System.Management/System.Management/ManagementScope.cs