troubleshooting Question

WiX - Custom Action Error - DLL is required for this install to complete

Avatar of CipherIS
CipherISFlag for United States of America asked on
Installation
29 Comments4 Solutions1034 ViewsLast Modified:
I have the below WiX code.  I created a Custom Action.  I have two issues.

1. I have to put the entire path for the SourceFile -> SourceFile="C:\MyDir\GetConnections.dll".  Anyway to shorten?
2.  I'm receiving an error "A DLL is required for this install to complete could not run." etc..  Can't figure out what is causing it.

<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
	<Fragment>
    <CustomAction Id="FillingListBox" BinaryKey="FillListBox" DllEntry="FillListBox" />
    
    <UI Id="DatabaseScreen">
      <Dialog Id="DatabaseDialog"
              Width="370"
              Height="270"
              Title="Database Connections"
              NoMinimize="no">

        <Control Id="BannerBitmap" Type="Bitmap" X="0" Y="0" Width="370" Height="44" TabSkip="no"
                 Text="!(loc.LicenseAgreementDlgBannerBitmap)" />

        <Control Id="Dbases" Type="ListBox" Sorted="no" 
                 Indirect="no" Property="DBaseValues" 
                 X="10" Y="50" Width="150" Height="180">
          <ListBox Property="DBaseValues">
            <ListItem Text="ARGHH!" Value="1"/>
          </ListBox>
        </Control>
        
        <Control Id="Title"
                 Type="Text"
                 X="15"
                 Y="23"
                 Width="280"
                 Height="15"
                 Transparent="yes"
                 NoPrefix="yes"
                 Text="Database Information" />

        <Control Id="InstallButton"
                 Type="PushButton"
                 Text="Install"
                 Height="17" Width="56"
                 X="300" Y="243"
                 TabSkip="yes">
          <Publish Event="EndDialog" Value="Return" />
        </Control>

        <Control Id="BackButton"
         Type="PushButton"
         X="235" Y="243"
         Height="17" Width="56"
         Text="Back">
          <Publish Event="NewDialog" Value="LicenseDialog" />
        </Control>

        <Control Id="CancelButton"
                 Type="PushButton"
                 X="10" Y="243"
                 Height="17" Width="56"
                 Text="Cancel">
          <Publish Event="SpawnDialog" Value="CancelDlg">1</Publish>
        </Control>
      </Dialog>

      <InstallUISequence>
        <Custom Action="FillingListBox" After="CostFinalize" />
        <Show Dialog="DatabaseDialog" After="FillingListBox" />
      </InstallUISequence>

    </UI>

    <Binary Id="FillListBox" SourceFile="C:\MyDir\GetConnections.dll" />
  </Fragment>
</Wix>
    public class DBase
    {
        public string Name { get; set; } = string.Empty;
    }

    public class CustomActions
    {
        [CustomAction]
        public static ActionResult GetSQLConnections(Session session)
        {
            session.Log("Begin GetSQLConnections");

            session["USER_DATABASES"] = "DefaultValue";

            int i = 0;
            int j = 0;
            string s = string.Empty;
            var dt = SmoApplication.EnumAvailableSqlServers(false);

            if (dt != null)
            {
                List<DBase> db = new List<DBase>();
                foreach (DataRow row in dt.Rows)
                {
                    foreach (var item in row.ItemArray)
                    {
                        if (i == j)
                        {
                            db.Add(new DBase()
                            {
                                Name = item.ToString()
                            });
                        }
                        else
                        {
                            break;
                        }
                        j++;
                    }
                    i++;
                }

                var z = (from y in db
                              select y).ToList();

                Microsoft.Deployment.WindowsInstaller.View listBoxView = session.Database.OpenView("SELECT * FROM ListBox");

                i = 1;
                foreach (var db1 in z)
                {
                    s += db1.Name + "; ";
                    Record newListBoxRecord = new Record(4);
                    newListBoxRecord[1] = "DBaseValues";
                    newListBoxRecord[2] = i;
                    newListBoxRecord[3] = db1.Name;
                    newListBoxRecord[4] = db1.Name;
                    listBoxView.Modify(ViewModifyMode.InsertTemporary, newListBoxRecord);
                    i++;
                }
            }
            //MessageBox.Show(s, "", MessageBoxButtons.OK, MessageBoxIcon.Information);

            return ActionResult.Success;
        }
    }
ASKER CERTIFIED SOLUTION
Vadim Rapp

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 4 Answers and 29 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 4 Answers and 29 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros