Hi all,

I'm getting my feet wet with controlling UI elements with custom
actions, and I'm stuck on dynamically driving ListBox content.  I've
been Googling and forum browsing for four hours and can't find a next
step, so here I am.

The WiX-built MSI has a ListBox table, which contains no records.
Orca defines the Order column as a short.  The custom action is
intended to insert a single temporary record into that table, check
for its existence, and return Success if it's there, Failure if it's
not.  Any exceptions thrown by the attempt to create the record are
recursively logged.

Nothing fancy, just trying to get a baseline from samples.  What I've
found here and elsewhere is that executing a View against the ListBox
table, creating a new record with the insert values, and modifying the
view with InsertTemporary should work.  It does not work, however, and
I'm out of ideas, so I have to ask very generally: What am I missing?

Here's the .NET source of the custom action:

        [CustomAction]
        public static ActionResult DotNetFillListbox(Session session)
        {

            AddListBoxEntry(session, "LISTBOXCONTENTS", 1, "FOO", "FOOBAR");

            int listBoxRowCount = session.Database.CountRows("ListBox");
            session.Log("{0} rows found in ListBox", listBoxRowCount);

            if (listBoxRowCount == 0)
                return ActionResult.Failure;
            else
                return ActionResult.Success;

        }

        private static void AddListBoxEntry(Session session, string
propertyName, int order, string value, string text)
        {
            View listBoxView = session.Database.OpenView("SELECT
`Property`, `Order`, `Value`, `Text` FROM `ListBox`");
            listBoxView.Execute();

            Record newEntry = new Record(4);
            newEntry[0] = propertyName;
            newEntry[1] = order;
            newEntry[2] = value;
            newEntry[3] = text;

            try
            {
                listBoxView.Modify(ViewModifyMode.InsertTemporary, newEntry);
            }
            catch (InstallerException ix)
            {
                RecurseLogInstallerException(session, ix, 0);
            }

            listBoxView.Close();

        }


Here's the relevant WiX source:

    <CustomAction Id="DotNetFillListbox"
BinaryKey="MyCustomActionBinary" DllEntry="DotNetFillListbox"
Execute="immediate" />
    <InstallUISequence>
      <Custom Action="DotNetFillListbox" After="CostFinalize" />
    </InstallUISequence>

This fails every time, giving the log results:

Action 18:55:42: DotNetFillListbox.
Action start 18:55:42: DotNetFillListbox.
SFXCA: Extracting custom action to temporary directory:
C:\DOCUME~1\stsmith\LOCALS~1\Temp\MSI1393.tmp-\
SFXCA: Binding to CLR version v2.0.50727
Calling custom action
CustomAction1!CustomAction1.CustomActions.DotNetFillListbox
InstallerException 1627:Function failed during execution. Database:
Table(s) Update failed.
0 rows found in ListBox
Action ended 18:55:42: DotNetFillListbox. Return value 3.

Note that the exception that's being thrown has no inner exception.
That entire message - "1627:Function failed during execution.
Database:  Table(s) Update failed" is all I get back.

Hopefully some brave soul has fought through this and can tell me what
I've missed!

Thanks in advance,
Steve

------------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It is the best place to buy or sell services for
just about anything Open Source.
http://p.sf.net/sfu/Xq1LFB
_______________________________________________
WiX-users mailing list
WiX-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wix-users

Reply via email to