Hello ,
I am facing a problem in using VIX api clone function with c# following is the sample code and the exception i am facing o can ssome help me by telling me whatz wrong with the code
-
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using VIX;
using Vestris.VMWareLib;
namespace ConsoleApplication10
{
class Program
{
static void Main(string[] args)
{
VIX.Host kl = VIX.VixCOMWrapper.Instance.Connect(VIX.Enums.VIX_SERVICEPROVIDER.VMWARE_WORKSTATION, "", 0, "", "");
VIX.VM vm = kl.OpenVM(@"E:\VMWares-xji\WIN2K3\Windows Server 2003 Standard Edition.vmx");
try
{
vm.Clone(VIX.Enums.VIX_CLONETYPE.FULL, "E:
VMWares-xji
clonedvm
kljh.vmx");
Console.WriteLine("clone taken");
Console.ReadLine();
}
catch (Exception e)
{
Console.WriteLine(e.ToString ());
Console.ReadLine();
}
}
}
}
and the exception
-
System.NullReferenceException: Object reference not set to an instance of an obj
ect.
at VIX.VM.Clone(Snapshot snapshot, VIX_CLONETYPE cloneType, String destConfig
PathName)
at VIX.VM.Clone(VIX_CLONETYPE cloneType, String destConfigPathName)
at ConsoleApplication10.Program.Main(String[] args) in C:\Users\MAI\Documents
\Visual Studio 2008\Projects\ConsoleApplication10\ConsoleApplication10\Program.c
s:line 21
You're either mixing using VMWare API directly (connecting, etc.) and Vestris VMWareTasks or you tried to modify this to use VixCOM directly. The code above won't compile, clone takes a VM handle. Get an instance of a virtual machine via the library and call Clone. This has been tested in VMWareTasks unit tests.
// declare a virtual host
VMWareVirtualHost virtualHost = new VMWareVirtualHost();
// connect to a local (VMWare Workstation) virtual machine
virtualHost.ConnectToVMWareWorkstation();
// open an existing virtual machine
VMWareVirtualMachine virtualMachine = virtualHost.Open("C:\Virtual Machines\xp\xp.vmx");
// clone
string vmxFileName = @"C:\Virtual Machines\xp\clone.vmx";
virtualMachine.Clone(VMWareVirtualMachineCloneType.Linked, vmxFileName);
Hi I am trying to clone a Virtual Machine usind C/C++ as a programming language and VIX API call which is
VixHandle VixVM_Clone(VixHandle vmHandle,
VixHandle snapshotHandle,
VixCloneType cloneType,
const char *destConfigPathName,
int options,
VixHandle propertyListHandle,
VixEventProc *callbackProc,
void *clientData);
But I am getting the error code 6 which is VIX_E_NOT_SUPPORTED and the VIX_PROPERTY_JOB_RESULT_HANDLE is showing 3010 which is VIX_E_NO_GUEST_OS_INSTALLED .
I first connected to the VM, then open the VM and then tried to Clone. When trying to clone I am getting the error which is Operation Not Supported.The VM I am trying to Clone is not running i.e., it is powerd off state.
I also tried to Clone using the vmrun but same results.
Can you please help me. Thanks a lot!
What are you using as the back end? VixVM_Clone is only suported in Workstation 6.5 and later.