We help IT Professionals succeed at work.
Get Started

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

CipherIS
CipherIS asked
on
1,025 Views
Last Modified: 2016-09-09
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>

Open in new window

    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;
        }
    }

Open in new window

Comment
Watch Question
CERTIFIED EXPERT
Commented:
This problem has been solved!
Unlock 4 Answers and 29 Comments.
See Answers
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE