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

Problems wrapping C API in C# - invalid parameters

$
0
0

 

Hi all,

 

 

In attempting to wrap the C VIX API in C#, I am getting error 3 back from the VIX API, that "One of the parameters was invalid"

 

 

Let's take VixHost_Connect() for example, the rest of my code follows the same example:

 

 

I use DLLImport as such (all my enumerations, such as VixServiceProvider, etc... are of type int):

 

 

public class Host {        [http://DllImport("vix.dll", EntryPoint = "VixHost_Connect", CallingConvention = CallingConvention.StdCall)|http://DllImport("vix.dll", EntryPoint = "VixHost_Connect", CallingConvention = CallingConvention.StdCall)]    public static extern VixHandle Connect(int apiVersion, VixServiceProvider hostType, string hostName,                int hostPort, string userName, string password, VixHostOptions options, VixHandle propertyListHandle,               IntPtr callbackProc, IntPtr clientData);    }

 

 

I then call this function as below (have added comments to show datatypes defined elsewhere:

 

 

class Program    {    static void Main(string[] args)            {    VixHandle jobHandle = vixConstants.INVALID_HANDLE;
VixHandle is an int    VixHandle hostHandle = vixConstants.INVALID_HANDLE;    VixError err;
VixError is an UInt64

 

 

    // connect to host

 

 

    jobHandle = Host.Connect(vixConstants.API_VERSION, VixServiceProvider.VMWARE_WORKSTATION, "", 0, "", "",                                        VixhostOptions.NONE, vixConstants.INVALID_HANDLE, IntPtr.Zero, IntPtr.Zero);             //API_VERSION  is and int (4)

 

 

    err = Job.Wait(jobHandle, VixPropertyID.JOB_HANDLE, ref hostHandle, VixPropertyID.NONE);                } }

 

 

At this point the Job.Wait() function returns 3 -- "One of the parameters was invalid". The same happens if I simply execute the Connect command and then check the jobTask's error code using Job.GetError.

 

 

-


 

 

I cannot use the COM interface because I am trying to use the clone function, which is only availiable in the C library.

 

 

-


 

 

  1. Am I missing something here, or should this work?

  2. Is there any more information on error 3 (causes, suggestions, more detailed explanation)?

  3. Is there more to this that installing the API, calling into the libraries and expecting it to work (workstation options, workstation needs to be running, etc)?

Thanks so much in advance for any help, if we can get this working, I will happily post the entire API wrapped in c# as well as an assembly to interface with VIX from .NET.

 

Evan Prothro

 

 

 

 

 


Viewing all articles
Browse latest Browse all 34639

Trending Articles