0
我有以下維克斯片段,調用取決於它是否安裝或卸載兩個自定義操作之一:Wix自定義操作屬性 - 爲什麼這不起作用?
<?xml version="1.0" encoding="UTF-8" ?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<?include $(sys.CURRENTDIR)\Config.wxi?>
<Fragment>
<CustomAction Id="caSetPropertyForInstall" Property="caRegisterDriver" Value="DeviceId=$(var.DriverId);DeviceName=$(var.ChooserName)" />
<CustomAction Id="caSetPropertyForUninstall" Property="caUnregisterDriver" Value="DeviceId=$(var.DriverId);DeviceName=$(var.ChooserName)" />
<Binary Id="DriverRegCA" SourceFile="$(var.ASCOM.Wix.CustomActions.TargetDir)\$(var.ASCOM.Wix.CustomActions.TargetName).CA.dll" />
<CustomAction Id="caRegisterDriver" BinaryKey="DriverRegCA" DllEntry="RegisterAscomDriver" Execute="deferred" Return="check" />
<CustomAction Id="caUnregisterDriver" BinaryKey="DriverRegCA" DllEntry="UnregisterAscomDriver" Execute="immediate" Return="ignore" />
<InstallExecuteSequence>
<Custom Action="caSetPropertyForInstall" Before="caRegisterDriver" />
<Custom Action="caSetPropertyForUninstall" Before="caUnregisterDriver" />
<!-- Execute during install -->
<Custom Action="caRegisterDriver" Before="InstallFinalize">NOT Installed</Custom>
<!-- Execute during uninstall -->
<Custom Action="caUnregisterDriver" Before="RemoveFiles">REMOVE ~= "ALL"</Custom>
</InstallExecuteSequence>
</Fragment>
</Wix>
安裝CA按預期工作。我在action中設置了一些屬性Id = caSetpropertyForInstall,然後操作caRegisterDriver調用我的C#託管自定義操作。 C#代碼查詢的自定義動作的屬性,像這樣:使用
var deviceId = session.CustomActionData["DeviceId"];
var deviceName = session.CustomActionData["DeviceName"];
Diagnostics.TraceInfo("Property DeviceId = [{0}]", deviceId);
Diagnostics.TraceInfo("Property DeviceName = [{0}]", deviceName);
相同的C#方法是否安裝或卸載,而且前面已經指出,這在安裝階段工作。
我的問題是,在卸載階段,我收到一個異常:
1 23/01/2013 03:07:37 7120 C:\Windows\SysWOW64\rundll32.exe ===== TiGra.Diagnostics Initialized: Default TraceLevel = Warning ===== 2 23/01/2013 03:07:37 7120 C:\Windows\SysWOW64\rundll32.exe ASCOM.Wix.CustomActions.CustomActions[Info]: Begin UnregisterAscomDriver custom action 3 23/01/2013 03:07:37 7120 C:\Windows\SysWOW64\rundll32.exe ASCOM.Wix.CustomActions.CustomActions[Error]: Error while querying installer properties 4 23/01/2013 03:07:37 7120 C:\Windows\SysWOW64\rundll32.exe ASCOM.Wix.CustomActions.CustomActions[Error]: System.Collections.Generic.KeyNotFoundException: The given key was not present in the dictionary. 5 23/01/2013 03:07:37 7120 C:\Windows\SysWOW64\rundll32.exe at System.ThrowHelper.ThrowKeyNotFoundException() 6 23/01/2013 03:07:37 7120 C:\Windows\SysWOW64\rundll32.exe at System.Collections.Generic.Dictionary`2.get_Item(TKey key) 7 23/01/2013 03:07:37 7120 C:\Windows\SysWOW64\rundll32.exe at Microsoft.Deployment.WindowsInstaller.CustomActionData.get_Item(String key) 8 23/01/2013 03:07:37 7120 C:\Windows\SysWOW64\rundll32.exe at ASCOM.Wix.CustomActions.CustomActions.CreateAscomDeviceFromSessionProperties(IInstallerPropertyProvider session) 9 23/01/2013 03:07:37 7120 C:\Windows\SysWOW64\rundll32.exe ASCOM.Wix.CustomActions.CustomActions[Error]: UnregisterAscomDriver failed: System.Collections.Generic.KeyNotFoundException: The given key was not present in the dictionary. 10 23/01/2013 03:07:37 7120 C:\Windows\SysWOW64\rundll32.exe at System.ThrowHelper.ThrowKeyNotFoundException() 11 23/01/2013 03:07:37 7120 C:\Windows\SysWOW64\rundll32.exe at System.Collections.Generic.Dictionary`2.get_Item(TKey key) 12 23/01/2013 03:07:37 7120 C:\Windows\SysWOW64\rundll32.exe at Microsoft.Deployment.WindowsInstaller.CustomActionData.get_Item(String key) 13 23/01/2013 03:07:37 7120 C:\Windows\SysWOW64\rundll32.exe at ASCOM.Wix.CustomActions.CustomActions.CreateAscomDeviceFromSessionProperties(IInstallerPropertyProvider session) 14 23/01/2013 03:07:37 7120 C:\Windows\SysWOW64\rundll32.exe at ASCOM.Wix.CustomActions.CustomActions.UnregisterAscomDriver(Session session)
我看不到我如何處理安裝和卸載任何區別,所以我很困惑,爲什麼這是。我錯過了明顯的東西嗎?
這工作,所以我接受了你的答案。如果我非常誠實,我不認爲我理解即時與延遲自定義操作的含義。你能詳細說明一下嗎? –
WebEx有一個小時左右的時間?以下是關於此主題的一些必讀內容:http://www.installsite.org/pages/en/isnews/200108/index.htm當我大約10年前第一次閱讀它時,我花了幾次才明白它。 –