[wix-users] Can't Access CustomData during uninstall
Paul McMillan, Sr.
pjm0677 at gmail.com
Wed Mar 27 12:14:43 PDT 2019
How do i get taken off this distribution list?
Sent from my iPhone
> On Mar 27, 2019, at 1:04 PM, Justin Cox via wix-users <wix-users at lists.wixtoolset.org> wrote:
>
> So the error was in my catch block, which I threw to an immediateCA error
> catcher, which sets a variable, then writes it to a log after exiting the
> CA. Fixing that, the error I'm getting now is:
>
> System.Collection.Generic.KeyNotFoundException: The given key was not
> present in the dictionary,
> at System.Collections.Generic.Dictionary'2.get_Item(TKey key)
> at XXXXXShared.DPWixExtension.UninstallFolders(Session session)
>
> So it still seems it's not getting the FolderList variable, even though the
> log shows it's being set. I'm stumped!
>
>
>
>> On Tue, Mar 26, 2019 at 8:11 PM Rob Mensching <rob at firegiant.com> wrote:
>>
>> The stack trace seems to show the custom action trying to set a property:
>>
>> at Microsoft.Deployment.WindowsInstaller.Session.set_Item(String
>> property, String value)
>>
>> PS: don't write your custom action like this, add temporary rows to tables
>> instead.
>>
>> _____________________________________________________________
>> Short replies here. Complete answers over there:
>> http://www.firegiant.com/
>>
>> -----Original Message-----
>> From: wix-users <wix-users-bounces at lists.wixtoolset.org> On Behalf Of
>> Justin Cox via wix-users
>> Sent: Tuesday, March 26, 2019 5:38 PM
>> To: WiX Toolset Users Mailing List (wix-users at lists.wixtoolset.org) <
>> wix-users at lists.wixtoolset.org>
>> Cc: Justin Cox <cox.justin.a at gmail.com>
>> Subject: [wix-users] Can't Access CustomData during uninstall
>>
>> I have custom scripts to backup folders during an install, rollback, and
>> uninstall. they all work except for the uninstall.
>> I set the value:
>> <CustomAction Id="SetFolderValuesUninstall" Property="UninstallFolders"
>> Value="FolderList=[INSTALLCLIENTINTERFACEDIR]"/>
>>
>> I execute the command:
>> <CustomAction Id="UninstallFolders" BinaryKey="XXXXXShared.CA.dll"
>> DllEntry="UninstallFolders" Return="check" Execute="deferred" />
>>
>> My C# code is:
>> [CustomAction]
>> public static ActionResult UninstallFolders(Session session)
>> {
>> ActionResult ar = ActionResult.Success;
>> try
>> {
>> string folderlist = session.CustomActionData["FolderList"];
>> MessageBox.Show("FolderList = " + folderlist);
>> List<string> foldersToDelete =
>> folderlist.Split('|').ToList();
>> ar = DeleteFolders(foldersToDelete, session);
>> return ar;
>> }
>> catch (Exception ex)
>> {
>> ar = immediateErrorCatcher(ex, session);
>> return ar;
>> }
>> }
>>
>> Everything works fine during the install, but during the uninstall, it
>> sets the value correctly:
>>
>> MSI (s) (60:04) [17:33:58:021]: PROPERTY CHANGE: Adding UninstallFolders
>> property. Its value is
>> 'FolderList=C:\inetpub\wwwroot\XXXXXClientInterface\'.
>>
>> Then, I get this error in verbose logging:
>> Calling custom action
>> XXXXXShared!XXXXXShared.DPWixExtension.UninstallFolders
>> Exception thrown by custom action:
>> System.Reflection.TargetInvocationException: Exception has been thrown by
>> the target of an invocation. --->
>> Microsoft.Deployment.WindowsInstaller.InstallerException: Cannot access
>> session details from a non-immediate custom action
>> at Microsoft.Deployment.WindowsInstaller.Session.ValidateSessionAccess()
>> at Microsoft.Deployment.WindowsInstaller.Session.set_Item(String
>> property, String value)
>> at XXXXXShared.DPWixExtension.immediateErrorCatcher(Exception ex,
>> Session ses)
>> at XXXXXShared.DPWixExtension.UninstallFolders(Session session)
>> --- End of inner exception stack trace ---
>> at System.RuntimeMethodHandle.InvokeMethod(Object target, Object
>> arguments, Signature sig, Boolean constructor)
>> at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj,
>> Object parameters, Object arguments)
>> at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags
>> invokeAttr, Binder binder, Object parameters, CultureInfo culture)
>> at
>>
>> Microsoft.Deployment.WindowsInstaller.CustomActionProxy.InvokeCustomAction(Int32
>> sessionHandle, String entryPoint, IntPtr remotingDelegatePtr) CustomAction
>> UninstallFolders returned actual error code 1603 (note this may not be 100%
>> accurate if translation happened inside sandbox)
>>
>>
>> the error is happening when I hite "string folderlist =
>> session.CustomActionData["FolderList"];"
>>
>> Is it possible to pass CustomActionData during an uninstall? Or has the
>> installer already thrown out those variables?
>>
>> ____________________________________________________________________
>> WiX Toolset Users Mailing List provided by FireGiant
>> http://www.firegiant.com/
>>
>
>
> --
>
> *Justin Cox*
>
>
>
> Senior Human Resource Manager
>
> T. 913-684-4819 *•* M. 304-617-4845 *•*cox.justin.a at gmail.com *•* United
> States Army *•*linkedin.com/in/jcox4
>
> ____________________________________________________________________
> WiX Toolset Users Mailing List provided by FireGiant http://www.firegiant.com/
More information about the wix-users
mailing list