[wix-users] Access Denied when invoking a custom action

Coryat, Jim Jim.Coryat at softprocorp.com
Mon Apr 4 07:44:33 PDT 2022


Some additional information, running the installer the first time succeeds.  Subsequent runs will fail with this message.

-----Original Message-----
From: wix-users <wix-users-bounces at lists.wixtoolset.org> On Behalf Of Coryat, Jim via wix-users
Sent: Friday, April 1, 2022 1:15 PM
To: WiX Toolset Users Mailing List <wix-users at lists.wixtoolset.org>
Cc: Coryat, Jim <Jim.Coryat at softprocorp.com>
Subject: Re: [wix-users] Access Denied when invoking a custom action

IMPORTANT NOTICE - This message sourced from an external mail server outside of the Company.

The custom action declration:
    <Binary Id="VSLocator" SourceFile="$(env.RD_BINARIES_PATH)\Setup\VSLocator.CA.dll"/>
    <CustomAction Id="VSFindInstances2" BinaryKey="VSLocator" DllEntry="VSFindInstances2" Execute="firstSequence"/> The custom action call
      <Custom Action="VSFindInstances2" After="VSFindInstances"></Custom>

The custom action class:
using System;
using System.Runtime.InteropServices;
using Microsoft.Deployment.WindowsInstaller;
using Microsoft.VisualStudio.Setup.Configuration;

namespace VSLocator {
    public class CustomActions {
        private const int REGDB_E_CLASSNOTREG = unchecked((int)0x80040154);

        [CustomAction]
        public static ActionResult VSFindInstances2( Session session ) {
            try {
                session.Log( "VSFindInstances2 Enter" );
                var query = new SetupConfiguration();
                var query2 = (ISetupConfiguration2)query;
                var e = query2.EnumAllInstances();

                var helper = (ISetupHelper)query;

                int fetched;
                var instances = new ISetupInstance[1];
                do {
                    e.Next( 1, instances, out fetched );
                    if ( fetched > 0 ) {
                        PrintInstance( instances[ 0 ], helper, session );
                    }
                }
                while ( fetched > 0 );
            }
            catch ( COMException ex ) when ( ex.HResult == REGDB_E_CLASSNOTREG ) {
                session.Log( "The query API is not registered. Assuming no instances are installed." );
            }
            catch ( Exception ex ) {
                session.Log( $"Error 0x{ex.HResult:x8}: {ex.Message}" );
            }
            return ActionResult.Success;
        }

        private static void PrintInstance( ISetupInstance instance, ISetupHelper helper, Session session ) {
            var instance2 = (ISetupInstance2)instance;
            var state = instance2.GetState();
            session.Log( $"InstanceId: {instance2.GetInstanceId()} ({( state == InstanceState.Complete ? "Complete" : "Incomplete" )})" );


            if ( ( state & InstanceState.Local ) == InstanceState.Local ) {
                var installationVersion = instance.GetInstallationVersion();
                var version = helper.ParseVersion(installationVersion);
                session.Log( $"InstallationVersion: {installationVersion} ({version})" );
                session.Log( $"InstallationPath: {instance2.GetInstallationPath()}" );

                // 32bit only discovery for now, remove this for 64bit too
                var installPath = instance2.GetInstallationPath();

                if ( installPath.Contains("\\Program Files (x86)\\") ) {
                    if ( installationVersion.StartsWith( "16." ) && string.IsNullOrEmpty( session[ "VS2019_ROOT_FOLDER]" ] ) ) {
                        session[ "VS2019_ROOT_FOLDER" ] = installPath;
                    }
                    if ( installationVersion.StartsWith( "17" ) && string.IsNullOrEmpty( session[ "VS2022_ROOT_FOLDER]" ] ) ) {
                        session[ "VS2022_ROOT_FOLDER" ] = installPath;
                    }
                }
            }
        }
    }
}
-----Original Message-----
From: wix-users <wix-users-bounces at lists.wixtoolset.org> On Behalf Of Steven Ogilvie via wix-users
Sent: Friday, April 1, 2022 11:12 AM
To: WiX Toolset Users Mailing List <wix-users at lists.wixtoolset.org>
Cc: Steven Ogilvie <stogilvie at genetec.com>
Subject: Re: [wix-users] Access Denied when invoking a custom action

IMPORTANT NOTICE - This message sourced from an external mail server outside of the Company.

You should show the custom action from your .wxs file and perhaps the custom action in the .cs file?

> -----Original Message-----
> From: wix-users <wix-users-bounces at lists.wixtoolset.org> On Behalf Of 
> Coryat, Jim via wix-users
> Sent: April 1, 2022 11:03 AM
> To: WiX Toolset Users Mailing List <wix-users at lists.wixtoolset.org>
> Cc: Coryat, Jim <Jim.Coryat at softprocorp.com>
> Subject: [wix-users] Access Denied when invoking a custom action
>
> Hi group,
>
> Running into an issue and don't understand why.  I created a standard 
> msi installer that installs support files and a Visual Studio 
> extension. It uses one C# custom action to identify the installed 
> instances of Visual Studio.  Really nothing special about the custom 
> action and the code is open source. I borrowed the class code from the 
> IsWix installer project.  For the person installing, the first time they run it, the installer will complete normally.
> Running it multiple times will cause a dialog to display when the 
> RunDll is invoked for the custom action:
>
> "There was a problem starting <path to dll>"
> Access is denied.
>
> Walking through the logs shows the custom action being invoked as the 
> precursor to the dialog and subsequent failure.
>
> Has anyone seen this before and what did you do to resolve it?
>
> Jim Coryat
> ________________________________
> NOTICE: The information contained in this message is proprietary 
> and/or confidential and may be privileged. If you are not the intended 
> recipient of this communication, you are hereby notified to: (i) 
> delete the message and all copies; (ii) do not disclose, distribute or 
> use the message in any manner; and (iii) notify the sender immediately.
>
>
>
> __________________________________________________________
> __________
> WiX Toolset Users Mailing List provided by FireGiant 
> https://nam04.safelinks.protection.outlook.com/?url=https%3A%2F%2Fcan01.safelinks.protection.outlook.com%2F%3Furl%3Dhttp%253A%252F%252Fwww&data=04%7C01%7CJim.Coryat%40softprocorp.com%7C5d16c7b94b674334c04f08da14033aaa%7C8a807b9b02da47f3a903791a42a2285c%7C0%7C0%7C637844301346693940%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=WB3oNGqDrVKyR6xR4gCcxBlx%2FTQYhIpCa1rG5eZEFLA%3D&reserved=0.
> firegiant.com%2F&data=04%7C01%7Cstogilvie%40genetec.com%7C7d4
> c19f606ef41dbacca08da13f0c052%7C7ba8d2fb46604a19802e4d015a17e167%7
> C0%7C0%7C637844221986376263%7CUnknown%7CTWFpbGZsb3d8eyJWIjoi
> MC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C300
> 0&sdata=UbFZPm4XHLIFvWJb4HtaUI7I9YWhPMSPH4Uh%2FxlB%2F2Q%
> 3D&reserved=0

____________________________________________________________________
WiX Toolset Users Mailing List provided by FireGiant https://nam04.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.firegiant.com%2F&data=04%7C01%7CJim.Coryat%40softprocorp.com%7C5d16c7b94b674334c04f08da14033aaa%7C8a807b9b02da47f3a903791a42a2285c%7C0%7C0%7C637844301346693940%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=3HYNIti4BcbUb4gwDL0eOgwiLdujNZB%2F2eyQ00cVieo%3D&reserved=0
________________________________
 NOTICE: The information contained in this message is proprietary and/or confidential and may be privileged. If you are not the intended recipient of this communication, you are hereby notified to: (i) delete the message and all copies; (ii) do not disclose, distribute or use the message in any manner; and (iii) notify the sender immediately.





____________________________________________________________________
WiX Toolset Users Mailing List provided by FireGiant https://nam04.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.firegiant.com%2F&data=04%7C01%7CJim.Coryat%40softprocorp.com%7C5d16c7b94b674334c04f08da14033aaa%7C8a807b9b02da47f3a903791a42a2285c%7C0%7C0%7C637844301346693940%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=3HYNIti4BcbUb4gwDL0eOgwiLdujNZB%2F2eyQ00cVieo%3D&reserved=0







More information about the wix-users mailing list