I know that such questions were asked in the past, but so far I have not yet been able to find a solution to my problem.
I have a system tray application that runs, and I want to close it before uninstalling and displays the "FileInUse" dialog, but everything I do does not seem to work. To close my application in the system tray, I need to create a file in the folder where it is installed. Then the application deletes the file and closes.
Depending on what I tried, the following problems occur:
1) The "FileInUse" dialog box appears. No good
2) The inability to invoke my custom action, which will create a file to notify my application in the system tray that it should close.
Error 1 ICE77: CloseAgentMonitor is a in-script custom action. It must be sequenced in between the InstallInitialize action and the InstallFinalize action in the InstallExecuteSequence table
3) I canβt transfer my application folder as a CustomData parameter to CustomAction if I set it to Immediate instead of Immediate , but if I set it to Deferred , I get the error mentioned in 2)
4) I tried different scenarios from invoking a user action to RemoveFiles , InstallValidate , InstallFinalize .
As I'm not sure what the correct sequences are, can someone tell me how and when to call my CustomAction so that it works, the "Delete" button is closed or before the files start to be deleted.
I want to do this when deleting files and before displaying the FileInUse dialog box.
Please note that it is really important that I can handle this in both silent and visual removal.
Thanks.
UPDATE:
I should probably post my wix code:
<CustomAction Id="CloseAgentMonitorSetProp" Return="check" Property="CloseAgentMonitor" Execute="immediate" Value="APPLICATIONFOLDER=[APPLICATIONFOLDER]" /> <CustomAction Id="CloseAgentMonitor" Return="check" Execute="immediate" BinaryKey="CustomActions.CA" DllEntry="CloseAgentMonitor" /> <InstallExecuteSequence> <!- Make sure to set the props before the CloseAgentMonitor custom action --> <Custom Action="CloseAgentMonitorSetProp" Before="CloseAgentMonitor"> <![CDATA[(Installed AND NOT UPGRADINGPRODUCTCODE)]]> </Custom> <Custom Action="CloseAgentMonitor" Before="InstallValidate"> <![CDATA[(Installed AND NOT UPGRADINGPRODUCTCODE)]]> </Custom> ...
Changing CustomAction to immediate and setting it before InstallValidate problem mentioned in 2, but it returns the error mentioned in clause 3, where it turns out that my CustomActionData not set, I even thought it should be, since it is called before CustomAction .
From my magazines you can see that this:
MSI (s) (30:08) [16:22:47:148]: Doing action: CloseAgentMonitorSetProp MSI (s) (30:08) [16:22:47:148]: Note: 1: 2205 2: 3: ActionText Action 16:22:47: CloseAgentMonitorSetProp. Action start 16:22:47: CloseAgentMonitorSetProp. MSI (s) (30:08) [16:22:47:148]: PROPERTY CHANGE: Adding CloseAgentMonitor property. Its value is 'APPLICATIONFOLDER=C:\Program Files (x86)\Company\Client\'. Action ended 16:22:47: CloseAgentMonitorSetProp. Return value 1.
But, as you can see, when my CustomAction , it causes an error when trying to access the APPLICATIONFOLDER .
MSI (s) (30:08) [16:22:47:148]: Doing action: CloseAgentMonitor MSI (s) (30:08) [16:22:47:148]: Note: 1: 2205 2: 3: ActionText Action 16:22:47: CloseAgentMonitor. Action start 16:22:47: CloseAgentMonitor. MSI (s) (30:1C) [16:22:47:148]: Invoking remote custom action. DLL: C:\Windows\Installer\MSI57B2.tmp, Entrypoint: CloseAgentMonitor MSI (s) (30:C0) [16:22:47:148]: Generating random cookie. MSI (s) (30:C0) [16:22:47:148]: Created Custom Action Server with PID 2528 (0x9E0). MSI (s) (30:F4) [16:22:47:195]: Running as a service. MSI (s) (30:F4) [16:22:47:195]: Hello, I'm your 32bit Impersonated custom action server. SFXCA: Extracting custom action to temporary directory: C:\Windows\Installer\MSI57B2.tmp-\ SFXCA: Binding to CLR version v4.0.30319 Calling custom action CustomActions!CustomActions.CustomActions.CloseAgentMonitor CloseAgentMonitor - Start IsAgentMonitorRunning - Start Checking if Agent Monitor is running. Agent Monitor running: True IsAgentMonitorRunning - End Checking CustomActionData - Start Checking CustomActionData - End Exception thrown by custom action: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.Collections.Generic.KeyNotFoundException: The given key was not present in the dictionary. at System.Collections.Generic.Dictionary`2.get_Item(TKey key) at Microsoft.Deployment.WindowsInstaller.CustomActionData.get_Item(String key) at CustomActions.CustomActions.CloseAgentMonitor(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 CloseAgentMonitor returned actual error code 1603 (note this may not be 100% accurate if translation happened inside sandbox) Action ended 16:22:47: CloseAgentMonitor. Return value 3. Action ended 16:22:47: INSTALL. Return value 3.