[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 849
  • Last Modified:

MSI-Wix combobox

Hi Experts,
 
I have a custom action that shows list of application pools in the system and want to bind these values into combobox which is inside customdlg.wxs and while executing MSI setup I should get a combobox that show list of app pools.

Please guide me how to bind custom action values to combobox in WIX?
custom action
//List all App pools    
public static ActionResult GetAppPools(Session session)
{
    using (ServerManager iisMgr=new ServerManager())
    {
        System.Collections.IEnumerator ie = iisMgr.ApplicationPools.GetEnumerator();
        List<string> apppools = new List<string>();

        while (ie.MoveNext())
        {
            apppools.Add(((Microsoft.Web.Administration.ApplicationPool)(ie.Current)).Name);
        }
    }
    return ActionResult.Success;
}

Open in new window


customdlg.wxs

<Control Id="ApplicationPoolLabel" Type="Text" Y="94" X="11" Width="349"  Height="16" TabSkip="no" Text="Application Pool: " />
<Control Id="ApplicationPoolCombo" Type="ComboBox" Y="94" X="100" Width="150" Height="16" ToolTip="Application Pool" Property="APP_POOL" Text="{80}">
    <ComboBox Property="APP_POOL">
        <ListItem Text="[APP_POOL]" Value="[APP_POOL]" />
    </ComboBox>
</Control>

Open in new window

0
ksd123
Asked:
ksd123
  • 2
  • 2
1 Solution
 
Vadim RappCommented:
Your custom action needs to populate table "combobox". Here's an example.
0
 
ksd123Author Commented:
Thank you.I just followed the above example and here is the updated code for filling app pools in the combobox.Please correct me if I miss anything.

 
[CustomAction]
        public static ActionResult FillApplicationPools(Session session)
        {
            if (null == session)
            {
                throw new ArgumentNullException("session");
            }
           
            // Debugger.Launch();
            
            View iview = session.Database.OpenView("SELECT * FROM ComboBox");
            iview.Execute();
            int lIndex = 1;

            DirectoryEntries appPools = new DirectoryEntry("IIS://localhost/W3SVC/AppPools").Children;
               
            foreach (DirectoryEntry appPool in appPools)
            {
               
                string applicationPoolName = appPool.Name;
                Record record = session.Database.CreateRecord(4);
                record.SetString(1, "APP_POOL");
                record.SetInteger(2, lIndex);
                record.SetString(3, applicationPoolName);
                record.SetString(4, applicationPoolName);
                iview.Modify(ViewModifyMode.InsertTemporary, record);
                ++lIndex;
            }

            iview.Close();
            return ActionResult.Success;
}

Open in new window


I have a question in the above stackflow example we have following code and did not understand why I need this and have  ignored while filling app pools in the combobox. Can you comment on this?

        ActionResult result;

        DataTable dt = SmoApplication.EnumAvailableSqlServers(false);
        DataRow[] rows = dt.Select(string.Empty, "IsLocal desc, Name asc");
        result = EnumSqlServersIntoComboBox(session, rows);
         return result;

Open in new window

0
 
Vadim RappCommented:
Because in their example they populated combobox with the names of available sql servers.
0
 
ksd123Author Commented:
Thank you
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now