简体   繁体   English

如何使用VIX(C#包装器)连接到vmware

[英]How can I connect to vmware using VIX (c# wrapper)

I'm trying to connect to VMWare Player machine using VMWareTasks (http://vmwaretasks.codeplex.com) but throw an error.. 我正在尝试使用VMWareTasks(http://vmwaretasks.codeplex.com)连接到VMWare Player计算机,但抛出错误。

// declare a virtual host
using (VMWareVirtualHost virtualHost = new VMWareVirtualHost())
{
    string vmfile = @"D:\SIRETIH-Releases\SIRETIH_Virtual\pc-virtual\siretih.vmx";
    // connect to the host
    virtualHost.ConnectToVMWarePlayer(); // <<-- this line throws an error... 

    using (VMWareVirtualMachine virtualMachine = virtualHost.Open(vmfile))
    {
        virtualMachine.WaitForToolsInGuest();
        virtualMachine.LoginInGuest("siretih", "");
    }
}

I'm using Visual Studio 2010 (C#), VMWareTasks, VmWare Player 4.0.2 build-591240 (Windows OS), Windows 7 ... 我正在使用Visual Studio 2010(C#),VMWareTasks,VmWare Player 4.0.2 build-591240(Windows OS),Windows 7 ...

virtual machine have vmware tools... 虚拟机具有vmware工具...

Do I need install anymore dll or api? 我是否需要再安装dll或api?

No se controló System.Exception
Message=Failed to connect: serviceProviderType="Player" hostName="" hostPort=0 username="" timeout=60
Source=Vestris.VMWareLib
  StackTrace:
en Vestris.VMWareLib.VMWareVirtualHost.Connect(ServiceProviderType serviceProviderType, String hostName, Int32 hostPort, String username, String password, Int32 timeout)
   en Vestris.VMWareLib.VMWareVirtualHost.ConnectToVMWarePlayer(Int32 timeoutInSeconds)
   en Vestris.VMWareLib.VMWareVirtualHost.ConnectToVMWarePlayer()utionContext, ContextCallback callback, Object state)

ConnectToVMWarePlayer() method has just one arg... there is a method "ConnectToVMWareVIServer" but I'm not using vmware server just player... ConnectToVMWarePlayer()方法只有一个参数。有一个方法“ ConnectToVMWareVIServer”,但我不是使用vmware服务器,而是播放器。

public void ConnectToVMWarePlayer(
    int timeoutInSeconds
)

A bit late I know, but how about the following way of getting a VMWareVirtualMachine object you can use: 我知道有点晚了,但是如何通过以下方式获取可以使用的VMWareVirtualMachine对象:

VMWareVirtualMachine virtualMachine = SetupVM(virtualHost, vmfile);

Just do a double check against null to make sure that you have an actual instance you can use. 只需对null进行仔细检查,以确保您具有可以使用的实际实例。 That is how I go about doing it, but maybe my use case is different than yours. 我就是这样做的,但是也许我的用例不同于您的用例。

I'm not sure if it is exactly the same, but the line of code you say is throwing an error needs the host and user credentials when connecting to VIServer: 我不确定是否完全相同,但是您所说的引发错误的代码行在连接VIServer时需要主机和用户凭据:

virtualHost.ConnectToVMWareVIServer(VMServerHost, VMServerUserName, VMServerPassword);

Can you provide that information to the VMWareVirtualHost.ConnectToVMPlayer method? 您可以将该信息提供给VMWareVirtualHost.ConnectToVMPlayer方法吗?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM