[wix-users] Can't Access CustomData during uninstall
Justin Cox
cox.justin.a at gmail.com
Tue Mar 26 17:37:50 PDT 2019
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?
More information about the wix-users
mailing list