Quantcast
Channel: VMware Communities : Popular Discussions - VIX API
Viewing all articles
Browse latest Browse all 34639

VMware VIX API FindItems() method never returns when querying for registered VMs

$
0
0

Hi,

 

I am using VMware Workstation 6.5 on Windows Vista x64.

I am trying to write some C# code that uses VMware Vix v1.6.1 COM API to get a list of registered virtual machines.

 

The code I am using is as follows:

 

    using System;

    using VixCOM;

     

    namespace ConsoleApplication48

    {

         internal class Program

         {

              private static void Main()

              {

                   var lib = new VixLibClass();

                   object results = null;

     

                   var job = lib.Connect(Constants.VIX_API_VERSION, Constants.VIX_SERVICEPROVIDER_VMWARE_WORKSTATION, null, 0,

    null, null, 0, null, null);

     

                   var err = job.Wait(new[] {Constants.VIX_PROPERTY_JOB_RESULT_HANDLE}, ref results);

 

               if (lib.ErrorIndicatesFailure(err))

                    Console.WriteLine("Error: " + err);

 

               var host = (IHost)((object[])results)[0];

 

               job = host.FindItems(Constants.VIX_FIND_REGISTERED_VMS, null, -1, new DiscoveryCallback(lib));

               job.WaitWithoutResults();

 

               host.Disconnect();

          }

     }

 

     internal class DiscoveryCallback : ICallback

     {

          protected VixLibClass lib;

 

          public DiscoveryCallback(VixLibClass lib)

          {

               this.lib = lib;

          }

 

          #region ICallback Members

 

          public void OnVixEvent(IJob job, int eventType, IVixHandle moreEventInfo)

          {

               // this method is never called

          }

 

          #endregion

         }

    }

 

 

I am aware that the COM dll is 32-bit, so I made sure that the test application is compiled as 32-bit.

Also I made sure that all VMware services are running.

 

There are no exceptions thrown, no errors returned (as far as I can see) and no events written into the event log.

 

Strangely enough the above code works when I try to get a list of running VMs using constant VIX_FIND_RUNNING_VMS.

 

Any ideas on what might be causing this?

 

 

Thanks,

 

Arnie


Viewing all articles
Browse latest Browse all 34639

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>