Подскажите, пожалуйста, что не так со следующим кодом?Я могу получить доступ к данным пользовательских действий во время установки и добавить их значения в коллекцию пользовательских действий сеанса.Однако во время удаления I пары значений отсутствуют в коллекции.
public class CustomActions
{
//This action is only called during application install
[CustomAction]
public static ActionResult CreateToolbar(Session session)
{
//This works fine the value is properly sent from wix script
//The variable toolbarName has the expected value
string toolbarName = session["VSTOCustomAction_ToolbarName"];
//Save the value for uninstaller
session.CustomActionData.Add("VSTOCustomAction_ToolbarName", toolbarName);
...
}
//This action is only called during application uninstall
[CustomAction]
public static ActionResult RemoveToolbar(Session session)
{
//Get the toolbar name and remove it
//Why does the following call return null?
string toolbarName = session.CustomActionData["VSTOCustomAction_ToolbarName"];
...
}
}
Below is the WIX part that calls the above custom action.
<!-- Include the VSTO Custom action -->
<Binary Id="VSTOCustomAction" SourceFile="CustomAction.CA.dll"/>
<CustomAction Id="CreateToolbar" BinaryKey="VSTOCustomAction" DllEntry="CreateToolbar" Execute="immediate"/>
<CustomAction Id="RemoveToolbar" BinaryKey="VSTOCustomAction" DllEntry="RemoveToolbar" Execute="immediate"/>
...
<CustomAction Id="PropertyAssign_ToolbarName" Property="VSTOCustomAction_ToolbarName" Value="MyToolBarName"/>
...
<!-- Modify the install sequence to call our custom action -->
<InstallExecuteSequence>
<Custom Action="PropertyAssign_ToolbarName" Before="CreateToolbar"><![CDATA[(&ToolbarComponent = 3) AND NOT (!ToolbarComponent = 3)]]></Custom>
<Custom Action="CreateToolbar" After="InstallFinalize"><![CDATA[(&ToolbarComponent = 3) AND NOT (!ToolbarComponent = 3)]]></Custom>
<Custom Action="RemoveToolbar" After="InstallFinalize"><![CDATA[(&ToolbarComponent = 2) AND NOT (!ToolbarComponent = 2)]]></Custom>
</InstallExecuteSequence>