【发布时间】:2012-03-05 09:12:26
【问题描述】:
我又遇到了一个问题,这可能很容易解决。
我想扩展使用 WiX 创建的设置,以更改已安装程序的配置文件。为此,我创建了一个 CustomAction。为了能够更改配置文件,我需要知道它在我的 CustomAction 中的(安装)位置。因此,我尝试将 INSTALLLOCATION 和文件名传递给我的 CustomAction。这就是问题所在:CustomActionData-属性始终为空,并且设置会引发异常。
我的 CustomAction 是一个 C# DLL 文件:DemoDatumErzeugen.CA.dll。它包含一个修改配置文件的方法DatumEintragen。我正在尝试以这种方式访问数据:
string path = session.CustomActionData["LOCATION"];
这是引发异常的地方。我只收到德语错误消息,但它说的是类似的内容:The supplied key was not found in the dictionary (Der angegebene Schlüssel war nicht im Wörterbuch angegeben.)。
这就是我尝试将属性从我的设置脚本传递给我的自定义操作的方式:
<Binary Id="DemoDatumEinrichtenCA" SourceFile="DemoDatumErzeugen.CA.dll"/>
<CustomAction Id="DemoDatum.SetProperty" Return="check" Property="DatumEintragen" Value="LOCATION=[INSTALLLOCATION];NAME=StrategieplanConfig.xml;"/>
<CustomAction Id="DemoDatum" BinaryKey="DemoDatumEinrichtenCA" DllEntry="DatumEintragen" Execute="deferred" Return="check" HideTarget="no"/>
<InstallExecuteSequence>
<Custom Action="DemoDatum.SetProperty" After="InstallFiles"/>
<Custom Action="DemoDatum" After="DemoDatum.SetProperty"/>
</InstallExecuteSequence>
我见过很多例子,它们以相同或至少非常相似的方式完成。我尝试了很多东西,但似乎没有什么比更改 <Custom Action="DemoDatum.SetProperty" After="InstallFiles"/> 中的值更有用。 CustomActionData 始终为零。
我检查它:session.CustomActionData.Count
再次感谢任何帮助或提示我做错了什么。
【问题讨论】:
标签: c# wix wix3.5 custom-action