VMware vSphere SDK with Visual Studio 2012
While trying latest Microsoft Visual Studio 2012 Express, I also played with the C# samples of the VMware vSphere SDK. Unfortunately, there isn’t direct support for VS 2012 but for VS 2010, 2008, and 2005. However, you can easily create project files for the VS 2012 by yourself assuming you are already familiar with the Visual Studio environment.
To get started, you still want to read the VMware document Developer’s Setup Guide first. The chapter 3 there is “Setting Up for Microsoft C# Development” and most contents are still applicable for the VS 2012.
I didn’t setup environment variables as suggested in the developer guide. Instead, I used the Developer Command Prompt for VS2012 which has environment variables ready. To start it, just click on the Windows Start button then All Programs, and select it from the list as shown below. As you can see the icon, the Developer Command Prompt for VS2012 is essentially a DOS prompt with which you type in commands.
Here are several commands I used to create the dlls using the Developer Command Prompt for VS2012.
wsdl.exe /n:VimApi vim.wsdl vimService.wsdl csc /t:library /out:Vim51Service2012.dll VimService.cs sgen /p Vim51Service2012.dll csc /t:library /out:Vim51Service2012.dll VimService.cs
It’s important to add the following time to the VimService.cs file after the sgen command, as documented in the guide: (yours file name could be different)
[System.Xml.Serialization.XmlSerializerAssemblyAttribute(AssemblyName = "Vim51Service2012.XmlSerializers")]
There are quite a few samples in the vSphere SDK package in the vsphere-ws\dotnet\cs\samples subdirectory under SDK home. There are 3 pre-defined solution files there already, each of which maps to a prior version of Visual Studio. But none of these solutions work out of box with Visual Studio 2012 simply because of the referenced DLLs are different.
To leverage these existing solutions, you can copy/paste and rename it to Samples2012.sln. Once you open it, you can fix the reference in each project. There are too many projects for me to fix, therefore I just create a new solution by myself.
To run the SimpleClient project, I copied and pasted then renamed a new project file called SimpleClient2012.csproj. After adding it into solution, I simply fixed the references to the latest dlls created earlier.
The SimpleClient will need to use VMware.Security.CredentialStore and AppUtil projects whose references need to be changed to new DLLs as with SimpleClient project.
Once these are done, you can rebuild the solution and the code should be ready to run. I assume you know these flows in Visual Studio as you’ve read this far.
Like its Java support, VMware’s support for C# in its vSphere SDK is far from mature. I can still see discussion like this one in the API forum. Even more problematic are the samples that are written in the same way as the Java samples, which bothered me so much that I created the de facto vijava API. We need something similar in C#/.Net too.