public override void Exec() { try { UIHierarchy solExplorer = this.ApplicationObject.ToolWindows.SolutionExplorer; UIHierarchyItem hierItem = (UIHierarchyItem)((System.Array)solExplorer.SelectedItems).GetValue(0); ProjectItem projItem = (ProjectItem)hierItem.Object; Cube cub = (Cube)projItem.Object; DeleteUnusedIndexesForm form1 = new DeleteUnusedIndexesForm(); form1.Init(projItem, cub.Parent, cub); form1.ShowDialog(); } catch (System.Exception ex) { MessageBox.Show(ex.Message + "\r\n\r\n" + ex.StackTrace, "BIDS Helper Delete Unused Indexes"); } }