I'm new to using vmware automation at least and I have VMWare server 1.0 installed.
I'd like to use the VIX Api in C#, but I haven't been able to load the vix.dll as a reference.
I've tried to find a way to do this, but it's all C code that I've found.
Any answers would be appreciated.
As a follow up, just to add more information, I'm using VStudio 2005 and the default Vix that came with the server install.
Thanks.
I would use VixCom,
You may need to install Vix API 1.1 (even though recommended not to) or the VMware Server Client
If using the newer API be sure to pass the version as 1 instead of the constant like shown in examples.
If you want to use VixCOM, then you will need to download VIX API 1.1. However, as has been said before, we recommend against using 1.1 with VMware Server. That being said, we have seen fewer issues with VIX API 1.1 on Windows than on Linux when being used with Server, and I believe zerovoid has had some success getting VixCOM to work with Server.
If you want to stick with the version of VIX installed with Server, then you will have to use the Platform Invoke (PInvoke) functionality in C# to call into vix.dll. This allows managed code to call into unmanaged C/C++ code that is in a DLL. A quick summary of PInvoke is here: http://msdn2.microsoft.com/en-US/library/aa446536.aspx.
Basically, you will need to create a class(es) with prototypes for the functions in the VIX API that you want to call, and an attribute telling Visual Studio that the function is found in vix.dll. Two things that you will need to pay attention to: make sure you use the right types to do the marshalling (VixError is 64 bits) and I'm not sure how well (if at all) PInvoke handles vararg functions.
Thanks to both of you for your help.
One more question, you mentioned that VixError is 64bits - will that run on 32bit systems?
I think I might just try the VIX API 1.1 since I'm running only on windows.
Yes, it will be fine on 32bit systems. The only thing you would have to worry about is using the correct value type in C# (UInt64 or ulong should be fine).
Yes, I had great success with VixCOM on Win32 through
C#, VB 2005, and WSH/VBS.
Thanks everyone. I've gotten a start at least.
I'll probably be back to ask more questions, but this'll hopefully get me going.
I don't know if you're still trying to get this working, but there is another route to take that I've found fairly successful. I first wrapped the Vix C API in a C++ class that did what I specifically needed, then used the SWIG library to import that into Ruby and Java. Both have been very successful and I haven't had any issues (at least none that weren't also present in straight C). I haven't tried C#, but I know that SWIG supports it, so if you're struggling with getting VixCOM to to work - take a look at SWIG.
Thanks. Through the COM interop using C# I've been pretty successful in getting the functionality that I'm looking for done. I have my own VMWare wrapper class now in C# that exposes what I need.
Thanks for the input about SWIG though. It looks like a pretty cool tool that I'll have to make a note of for the future.
Would you be willing to share that wrapper class out? I'm having difficulties with VixCOM ![]()
What sort of difficulties are you having with VixCOM? Which product are you trying to use it with?
Solved the problem! Never mind. Had the wrong server file name specified.
I am new to using VIXCom. When i try to connect to server sometimes it is getting success and sometimes getting failure.When i run a loop for connect it is connecting successfully at 2nd or 3rd attempt. Please help! Thanks in Advance.
Use VMWareTasks. Aside of shameless advertising, unless you're doing asynchronous VM operations, I don't see any reasons to use raw VixCOM API.
