Question

I'm trying to connect to VMWare Player machine using VMWareTasks (http://vmwaretasks.codeplex.com) but throw an error..

// 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 ...

virtual machine have vmware tools...

Do I need install anymore dll or 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...

public void ConnectToVMWarePlayer(
    int timeoutInSeconds
)
Was it helpful?

Solution

A bit late I know, but how about the following way of getting a VMWareVirtualMachine object you can use:

VMWareVirtualMachine virtualMachine = SetupVM(virtualHost, vmfile);

Just do a double check against null to make sure that you have an actual instance you can use. That is how I go about doing it, but maybe my use case is different than yours.

OTHER TIPS

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:

virtualHost.ConnectToVMWareVIServer(VMServerHost, VMServerUserName, VMServerPassword);

Can you provide that information to the VMWareVirtualHost.ConnectToVMPlayer method?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top