An unhandled exception of type 'System.IndexOutOfRangeException' occurred Additional information: Item not found > ISWiAutomation.ISWiProductConfigs.Item...When the following executes at runtime:
oProdConfig = (ISWiProductConfig) oISProj.ISWiProductConfigs["Default"];The following cleaned up version which complies and runs:
using System; using System.Drawing; using System.Collections; using System.ComponentModel; using System.Windows.Forms; using System.Data; using System.IO; using ISWiAutomation; <snip> private void frmMain_BuildISProj() { if ( txtProjectFile.Text != "" ) { string strProjectFile; strProjectFile = txtProjectFile.Text.Trim(); // Create IS object and open project file ISWiProjectClass oISProj = new ISWiProjectClass(); oISProj.OpenProject(strProjectFile, false); //-- Build release ISWiProductConfig oProdConfig; ISWiRelease oRelease; //-- We only have one Product Configuration and it's named "Default" oProdConfig = (ISWiProductConfig) oISProj.ISWiProductConfigs[1]; for ( int i = 1; i <= oISProj.ISWiProductConfigs.Count; i++ ) { if (oISProj.ISWiProductConfigs[i].Name == "Default") { oProdConfig = oISProj.ISWiProductConfigs[i]; } } //-- We only have one Release and it's named "Network" oRelease = (ISWiRelease) oProdConfig.ISWiReleases[1]; for ( int i = 1; i <= oProdConfig.ISWiReleases.Count; i++ ) { if (oProdConfig.ISWiReleases[i].Name == "Network") { oRelease = oProdConfig.ISWiReleases[i]; } } oRelease.Build(); // Other option?: // oISProj.ISWiProductConfigs[1].ISWiReleases[1].Build(); oISProj.SaveProject(); oISProj.CloseProject(); oISProj = null; oProdConfig = null; oRelease = null; } // txtProjectFile.Text != "" } // frmMain_BuildISProj()