I am facing a problem in using VIX api clone function with c#

Jun 19, 2009 at 2:06 PM

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 <!-- BEGIN attachments --><!-- END attachments -->

Coordinator
Jun 19, 2009 at 2:12 PM

Hi!

You might want to check that the variable vm isn't null before you try to use the Clone() method. This can happen when the OpenVM() method didn't work.

Best regards,
Alex

Jun 19, 2009 at 2:36 PM

Hello Alex,

                      Thanx for ur reply, but variable is not null and the error remains the same. so can u check the above mentioned code at ur machine

 

 

 thanx in advance

papapa

 

            

Coordinator
Jun 19, 2009 at 3:59 PM

Hi!

I corrected a mistake in the code, can you please download the new revision via the Source Code tab, compile it and test if it works (I can't test it because I have only VMware Server 2, which doesn't support cloning).

Best regards,
Alex

Jun 23, 2009 at 11:42 AM

Hello,

           Thanks for reply but i didnot find the VixCOMWrapper.dll in the source code tab can u tell where it is?

 

thanx

papapa

Coordinator
Jun 24, 2009 at 11:25 AM

Hi!

You have to download the complete source-code and compile the VixCOMWrapper.dll yourself in Visual Studio by clicking on Build -> Build Solution.

Best regards,
Alex