So I've decided to start right at the very beginning. If you're going to build an app in .NET using the VI3 SDK, you need the DLL files with all the stub classes. And since the DLLs distributed with my MAC tool were from the VirtualCenter 2.0.0 version of the SDK, I've decided to rebuild them using the 2.0.1 version.
I should note at this point, that building these DLLs has gotten much easier since the original release. When you extract the SDK components you are supplied with a script that would build this DLL for you; however when you use the DLL generated from it you get stuck with a bug that makes it incredibly slow to create a VimService instance. This is all documented in a VMWare knowledge base article, along with how to work around it. If you go and read that article, you can see the instructions I had to follow to make the MAC-tool DLLs - all that stuff that's now listed as "Alternative 2: Step-by-Stem Instructions". But with the 2.0.1 release, that KB article has been updated with a patch that makes this procedure very easy.
So - to actually build these DLLs, you will need a few things.
- Visual Studio 2005. I have a license for the Professional edition, however the free Express editions will work just as well.
- The VI3 SDK. I recommend grabbing the documentation while you're there.
- The patch to automate building DLLs without performance problems. Scroll to the very bottom of that article to find the patch attached.
Install Visual Studio if you haven't already, and extract both the SDK and the patch. From this point on I'm going to assume that you've extracted the SDK to C:\Temp\SDK\ and the patch to C:\Temp\patch\. To make really sure that we're talking the same directories, in the C:\Temp\SDK\ folder you should find 2 more folders and 2 .wsdl files, and in the C:\Temp\patch\ folder there should be 8 files - mostly .txt and .cmd.
Next step is to open up a Visual Studio command prompt. Make sure it's a Visual Studio one and not just regular cmd.exe as the VS one has a lot more environment variables defined. You can find the shortcut somewhere in the Visual Studio program group. You'll know you got the right one if at the top when it starts it says "Setting environment for using Microsoft Visual Studio 2005 x86 tools." Then it's just a matter of typing a few commands.
CD \Temp\patch patch201.cmd
C:\Temp\SDK
CD \Temp\SDK
\samples_2_0\DotNet
Build2005.cmd
When that last command finishes, you'll find a couple of brand new DLLs for you in the C:\Temp\SDK\samples_2_0\DotNet\ folder. You can copy them to wherever you like, and if you don't want the sample code it is safe at this point to delete both the SDK folder and the patch folder. The only things you
need are VimService2005.dll and VimService2005.XmlSerializers.dll.
Or if you're lazy, I've put compiled versions up in a place where you can
snag them from. If you have problems extracting that, go and get
7-Zip.
Now besides being a slightly newer version than my older DLLs, there is another significant difference with this version (besides file names). All of the objects in this version are in the VimApi namespace. So an object from my DLL named say VimService, in this new DLL will be called VimApi.VimService. The really easy way to make code written for the old DLL work is to just add this line to the top of every file.
Imports VimApi
After thats done, you can reference all the objects without having to type 'VimApi.' in front of everything. To port my VIClient.DLL to this new VimService2005, all I had to do was remove the old DLL reference, add a reference to VimService2005, and add the Imports line at the top.