[solved] Unable to connect to VMWare Workstation

Feb 18, 2010 at 3:53 PM

Hi,

I a new to using this library so forgive me if I'm asking stupid questions. For some reason I am unable to connect to VMWare workstation.

My setup:

  • - VMWare workstation version 7.0.1
  • - VMWare tasks 1.4
  • .NET Framework 3.5
  • Installed 1 VMWare with Windows XP

I am using the following code from the manual:

 

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Vestris.VMWareLib;

namespace VMWare
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();

            VMWareVirtualHost virtualHost = new VMWareVirtualHost();

            // connect to a local VMWare Workstation virtual host
            virtualHost.ConnectToVMWareWorkstation();
            // open an existing virtual machine
            VMWareVirtualMachine virtualMachine = virtualHost.Open(@"C:\Users\Andries\Documents\Virtual Machines\Windows XP Home Edition\Windows XP Home Edition.vmx");
            // power on this virtual machine
            virtualMachine.PowerOn();
            // wait for VMWare Tools
            virtualMachine.WaitForToolsInGuest();
            // login to the virtual machine
            virtualMachine.LoginInGuest("Administrator", "password");
            // run notepad
            virtualMachine.RunProgramInGuest("notepad.exe", string.Empty);
            // create a new snapshot
            string name = "New Snapshot";
            // take a snapshot at the current state
            virtualMachine.Snapshots.CreateSnapshot(name, "test snapshot");
            // power off
            virtualMachine.PowerOff();
            // find the newly created snapshot
            VMWareSnapshot snapshot = virtualMachine.Snapshots.GetNamedSnapshot(name);
            // revert to the new snapshot
            snapshot.RevertToSnapshot();
            // delete snapshot
            snapshot.RemoveSnapshot();

        }
    }
}

The code throws the following exception at the line where it tries to connect to the VMWare workstation: "virtualHost.ConnectToVMWareWorkstation();"

Vestris.VMWareLib.VMWareException was unhandled
  Message="The specified version was not found"
  Source="Vestris.VMWareLib"
  ErrorCode=22002
  StackTrace:
       bij Vestris.VMWareLib.VMWareInterop.Check(UInt64 errCode)
       bij Vestris.VMWareLib.VMWareJob..ctor(IJob job, VMWareJobCallback callback)
       bij Vestris.VMWareLib.VMWareVirtualHost.Connect(ServiceProviderType serviceProviderType, String hostName, Int32 hostPort, String username, String password, Int32 timeout)
       bij Vestris.VMWareLib.VMWareVirtualHost.ConnectToVMWareWorkstation(Int32 timeoutInSeconds)
       bij Vestris.VMWareLib.VMWareVirtualHost.ConnectToVMWareWorkstation()
       bij VMWare.Form1..ctor() in C:\Users\Andries\Documents\Visual Studio 2008\Projects\VMWare\VMWare\Form1.cs:regel 22
       bij VMWare.Program.Main() in C:\Users\Andries\Documents\Visual Studio 2008\Projects\VMWare\VMWare\Program.cs:regel 18
       bij System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
       bij System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
       bij Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
       bij System.Threading.ThreadHelper.ThreadStart_Context(Object state)
       bij System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       bij System.Threading.ThreadHelper.ThreadStart()
  InnerException:

I'd appreciate it if anyone could point me into the right direction.

Thanks in advance,

Andriesss

Coordinator
Feb 18, 2010 at 10:05 PM

This is an error straight from the VixCOM API. I would ask the VixCOM forum. My first guess would be that you don't have VixCOM 1.8.1 installed.

Feb 23, 2010 at 8:31 PM

Thank you, my issue got resolved by installing the VixCOM 1.8.1 library found at:
http://www.vmware.com/downloads/download.do?downloadGroup=VIX-API-181

Regards,

Andries