[wix-users] SourceList class in custom actions

Bevan Weiss bevan.weiss at gmail.com
Wed Mar 11 12:50:08 PDT 2020


I believe ProductInstallation is primarily for already installed products.
Based upon the class wrapping this function
https://docs.microsoft.com/en-au/windows/win32/api/msi/nf-msi-msigetproducti
nfoa?redirectedfrom=MSDN

When your CustomAction is called, is your Product already installed or
advertised?

Regards,
Bevan

-----Original Message-----
From: wix-users <wix-users-bounces at lists.wixtoolset.org> On Behalf Of
Matthias Reuss via wix-users
Sent: 12 March 2020 01:31
To: WiX Toolset Users Mailing List <wix-users at lists.wixtoolset.org>
Cc: Matthias Reuss <matthias.mr.reuss at wsa.com>
Subject: [wix-users] SourceList class in custom actions

Hello,

I tried to use the SourceList class in a custom action.

As a result, I get exceptions when retrieving Sourcelist items.

To get more into detail, I wrote a custom action like this:

        [CustomAction]
        public static ActionResult GetSourceList(Session session)
        {
                string currentProductCode = session["ProductCode"];

                string productName = session["ProductName"];

                ProductInstallation productInstallInfo = new
ProductInstallation(currentProductCode);
                SourceList mySourceList = productInstallInfo.SourceList;

    _logger.Log("SourceList:");
                    try
                    {
                        _logger.Log($"Count: {mySourceList.Count}");
                    }
                    catch (Exception ex)
                    {
                        _logger.Log("Exception when retrieving SourceList
properties:" + ex.ToString());
                    }
                    try
                    {
                        _logger.Log($"DiskPrompt:
{mySourceList.DiskPrompt}");
                    }
                    catch (Exception ex)
                    {
                        _logger.Log("Exception when retrieving SourceList
properties:" + ex.ToString());
                    }

[...]

return ActionResult.Success;

        }
    }

and scheduled it after InstallValidate.
This code results in
CustomActionDLL {13:48:9:688}: Exception when retrieving SourceList
properties:System.ArgumentException: The parameter is incorrect.
   at Microsoft.Deployment.WindowsInstaller.SourceList.get_Item(String
property)
   at Microsoft.Deployment.WindowsInstaller.SourceList.get_DiskPrompt()

for the following SourceList attributes:
DiskPrompt
LastUsedSource
LastUsedType
MediaPackagePath
PackageName

and also in an exception when retrieving the Count.

Am I missing something here?
In the documentation, I did not find any restrictions about using the
SourceList object or the underlying MsiSourceList* functions in custom
action context.

Best regards

Matthias Reuss




____________________________________________________________________
WiX Toolset Users Mailing List provided by FireGiant
http://www.firegiant.com/




More information about the wix-users mailing list