Getting Vmware exception while opening virtual machine

Mar 4, 2010 at 3:48 PM

Guys when i run the following code , i get error virtual machine can not be found 

 

 

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
//using VMwareBridgeLib;
using VixCOM;
using Vestris.VMWareLib;
namespace ConsoleApplication3
{
    class Program
    {
        static void Main(string[] args)
        {
            VMWareVirtualHost vh = new VMWareVirtualHost();
            try
            {
                Console.WriteLine("hi1");
                Console.WriteLine("hi2");
                System.Uri u = new Uri("https://abc-e59b61f2f2e:8333/ui/#");
                // Console.WriteLine(vh.ConnectionType);
                vh.ConnectToVMWareVIServer("localhost:8333", "rohit", "rohit");
                Console.WriteLine("connected to server");
                //IVM2 vm = new 
                VMWareVirtualMachine vm = vh.Open("F:\\Virtual Machines\\xp1\\xp1.vmx");
                Console.WriteLine("Virtual machine found");
            }
            catch (Exception e)
            {
                Console.WriteLine("Inside catch-------------------------" + e.StackTrace + "=======" + e);
            }
        }
    }
}

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using VixCOM;

using Vestris.VMWareLib;

 

 

namespace ConsoleApplication3

{

    class Program

    {

        static void Main(string[] args)

        {

            VMWareVirtualHost vh = new VMWareVirtualHost();

            try

            {

 

                vh.ConnectToVMWareVIServer("localhost:8333", "rohit", "rohit");

                Console.WriteLine("connected to server");

                VMWareVirtualMachine vm = vh.Open("F:\\Virtual Machines\\xp1\\xp1.vmx");

                Console.WriteLine("Virtual machine found");

 

            }

            catch (Exception e)

            {

                Console.WriteLine("Inside catch-------------------------" + e.StackTrace + "=======" + e);

            }

 

        }

    }

}

I get an exception vestris.Vmwarelib.vmware excption i.e; virtual machine can not be found , though the machine mentioned in a code does exist on
given path and it's vmx file also exists , Also connection gets established with the vmware server.
Please help me..........

 

Coordinator
Mar 5, 2010 at 5:21 AM
For a VMWare Server or a VMWare ESX the path is a [storage] path that you can get from the properties of the VM, not a physical path on disk.
Mar 5, 2010 at 8:09 AM

dblok, will you please elaborate what are u saying? The vmx file for virtual machine exists on path F:\\Virtual Machines\\xp1\\xp1.vmx but on vmware server i get error :

Invalid datastore format 'F:\Virtual Machines\xp1\xp1.vmx'.

 

 

Coordinator
Mar 5, 2010 at 12:11 PM

Look at the samples here (and in the documentation). The path to the vmx file is a virtual one on the VI server.

// declare a virtual host
VMWareVirtualHost virtualHost = new VMWareVirtualHost();
// connect to a remote (VMWare ESX) virtual machine
virtualHost.ConnectToVMWareVIServer("esx.mycompany.com", "vmuser", "password");
// open an existing virtual machine
VMWareVirtualMachine virtualMachine = virtualHost.Open("[storage] testvm/testvm.vmx");
Mar 5, 2010 at 1:40 PM

dblock thank you very much , It worked.

Mar 5, 2010 at 2:24 PM

When i  power on the machine , i can see from vmware server that machine is powered on but i get          vmware exception: Timeout error while waiting for the guest tools to start.            Can u please tell me what this is?

Coordinator
Mar 11, 2010 at 5:44 PM

This means that the VixCOM WaitForToolsInGuest timed out. Increase the timeout if it's really a timeout problem (it's an optional parameter) or see whether your server comes up with VMWare tools running.

I've seen odd behavior with VMWare Server where manually logging into the server does something that makes the WaitForToolsInGuest call succeed. I don't know what to do in that case.