6.0

Table Of Contents
VMware, Inc. 31
B
When you generate the .NET stubs to run C# samples in the SDK, you get best performance if you pre-compile
the XML serializers into separate DLLs. The procedure in “Build the C# vSphere DLLs” on page 20 describes
how to pre-compile the XML serializers and modify the class declaration to use a pre-compiled serializer DLL.
The result of these changes is to decrease initialization time when you instantiate the VimService class.
You can choose to script the procedure to build the DLLs. Using a script reduces the chance of errors and is
faster than doing the procedure manually. This example script illustrates the procedure to build the DLLs with
pre-compiled serializers.
This example script requires several environment variables to locate the source files and tools. The script also
requires that you install a SED utility, which it uses to make the necessary changes to the C# source. You can
find SED for Windows, or other capable tools, on the Web.
Example B-1. Example Script To Build C# DLLs
@echo off
if "%WS_SDK_HOME%"=="" (
echo Set WS_SDK_HOME=^<absolute path to vsphere-ws directory of unzipped SDK^>.
goto end
)
if "%WSDL_HOME%"=="" (
rem This long line wraps:
echo Set WSDL_HOME=%WS_SDK_HOME%\vsphere-ws\wsdl\vim25 ^(or absolute path to directory
containing vim and vim25 WSDL subdirectories^).
goto end
)
if "%SED_HOME%"=="" (
echo Install SED and Set SED_HOME=^<absolute path to directory containing sed.exe^>.
goto end
)
if not exist %WS_SDK_HOME%\vsphere-ws\dotnet\cs\samples (
rem This long line wraps:
echo Did not find %WS_SDK_HOME%\vsphere-ws\dotnet\cs\samples directory. Please unzip SDK
files and check WS_SDK_HOME setting.
goto end
)
cd %WS_SDK_HOME%\vsphere-ws\dotnet\cs\samples
echo "Building Vim25Api namespace DLLs..."
if exist VimService.cs* del VimService.cs*
rem This long line wraps:
wsewsdl3.exe /n:Vim25Api /type:webClient /l:CS "%WSDL_HOME%\vim.wsdl"
"%WSDL_HOME%\vimService.wsdl"
if exist Vim25Service.dll del Vim25Service.dll
rem This long line wraps:
csc.exe /t:library /out:Vim25Service.dll /r:"%WSE_HOME%\Microsoft.Web.Services3.dll"
VimService.cs
echo "...Generating Vim25Api serializers..."
if exist Vim25Service.XmlSerializers.dll del Vim25Service.XmlSerializers.dll
sgen /p Vim25Service.dll
Scripting the C# DLL Build
B