[wix-users] SourceList class in custom actions

Matthias Reuss matthias.mr.reuss at wsa.com
Wed Mar 11 07:31:10 PDT 2020


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





More information about the wix-users mailing list