Readme for VI SDK 2.5.0 .NET (DotNet) Samples

VMware Infrastructure SDK 2.5.0 Readme
Readme for Java samples

This document includes these topics:

Building the Samples

You can build the C# (.NET) samples using Microsoft Visual C# 2005 Express, Microsoft Visual Studio 2005, or Microsoft Visual Studio 2003. However, note that Visual Studio 2003 is not recommended, due to a performance issue. See Knowledge Base article 87402 (“.NET Takes a Long Time to Instantiate the VimService Class”) for a discussion of the issue.

Building the Samples Using Visual Studio 2005 or Visual Studio 2003

  1. Open a Visual Studio .NET command prompt from the Windows Start Menu:
    • Select Start Menu –> All Programs –> Visual Studio .NET –> Visual Studio .NET Tools –> Visual Studio .NET Command Prompt
  2. Navigate to the SDK\samples\DotNet sub-directory.
  3. Execute Build2005.cmd by entering the filename on the command line.

Building the Samples Using Visual C# 2005 Express

Select the default (Full) Microsoft Visual C# 2005 Express installation.

If your Microsoft Visual C# 2005 Express installation has not been configured using default locations, you must:

  • Create a VSINSTALLDIR environment variable (System environment variable);
  • Set the VSINSTALLDIR environment variable to the locations of the Microsoft’s Visual Studio tools and .NET Framework 2.0 (in the Common7 and SDK sub-directories of the Microsoft Visual C# 2005 Express installation, which, by default, is in c:\Program Files\Microsoft Visual Studio 8\Common7 and c:\Program Files\Microsoft Visual Studio 8\SDK). Use quotation marks around directory names that have spaces in them. For example:
    “C:\apps\Microsoft Visual Studio 8”

If Visual C# Express is installed in the default location (“c:\Program Files\Microsoft Visual Studio 8”), you do not need to create or set the VSINSTALLDIR environment variable.

To build the samples using the Visual C# 2005 Express:

  1. Open a Visual Studio .NET command prompt from the Windows Start Menu:
    • Select Start Menu –> All Programs –> Visual Studio .NET –> Visual Studio .NET Tools –> Visual Studio .NET Command Prompt
  2. Navigate to the SDK\samples\DotNet directory.
  3. Execute Build2005.cmd:

Running the Samples

The DotSamples can be executed from within the \bin or \debug directory of each project. You can also run the samples from within Visual Studio, at the .NET command prompt.

To display help text for any application, simply run the application without any parameters.

To run any sample from within Visual Studio:

  1. Launch Visual Studio.
  2. Open the Samplesnnnn.sln file (where nnnn is 2003 or 2005—Visual Studio 2005 is recommended).
  3. Set the Startup Project to any of the projects present in the solution. For example, right-mouse click on the Browser2005 Project and then select Set as Startup Project from the menu.
  4. Change the Project Properties to specify the command line arguments:
    • From the Project menu, select Properties to display the Property Pages dialog.
    • In the Project_Name Property Pages dialog, select Configuration Properties—Debugging in the left-hand pane.
    • In the right-hand pane (under Start Options), select Command Line Arguments.
    • Click OK to save your changes.
  5. Run the sample at the command prompt.

Sample Applications

SampleDescription, command-line syntax, and example...
Browser Gets contents of the Service starting at the root folder, and prints out listing. Optionally, obtain properties for a specific type, or by default, for ManagedEntity.

Command line syntax:
Browser <webserviceurl> <username> <password> [<mo type> <property name> ...]

Browser http://my-server/sdk myuser mypaswd
Browser http://myserver/sdk myuser mypaswd VirtualMachine name

ConnectConnects to service, logs into service, and logs out of service.

Command line syntax:
Connect <webserviceurl> <username> <password>

Connect http://my-server/sdk myuser mypaswd


Retrieve and Format the latest event. Demonstrates Event formatting.

Command line syntax:
EventFormat <webserviceurl> <username> <password>

EventFormat http://my-server/sdk myuser mypaswd

SimpleClientCode that demonstrates connecting to service, logging on to service, obtaining service content, and logging out from service.

Command line syntax:
SimpleClient <webserviceurl> <username> <password>

SimpleClient http://my-server/sdk myuser mypaswd

VmPowerOps Retrieves a reference to a vm and invokes various power operations on it, as specified on the command line options.

Command line syntax:
VmPowerOps <webserviceurl> <username> <password> <anyvm|namedvm> <vmname> <on|off|suspend|reset> <normal|hard|softOrFail|softOrHard> <hostname>

VmPowerOps http://my-server/sdk myuser mypaswd myWin2k3_ProductionVM on normal myhost.mycompany.com


Monitors updates on a particular virtual machine using the PropertyCollector.

Command line syntax:
WatchVM <webserviceurl> <username> <password> <inventory-path-to-vm>

WatchVM http://my-server/sdk myuser mypaswd Datacenter1/vm/myvm

See the Developer’s Setup Guide for complete information.

VMware Resources

Copyright © 2007, 2008 VMware, Inc. All rights not expressly granted herein are reserved.

Last updated 26-Dec-2007 7:00 pm  |  VI SDK 2.5 | online