once again I'm stuck at a problem, that is probably easy to solve.
I want to extend a setup, created with WiX, to make changes in the configuration file of the installed program. In order to do this I've created a CustomAction. To be able to change the configuration file, I need to know the (install-)location of it within my CustomAction. Therefore I try passing the INSTALLLOCATION and Filename to my CustomAction. Here lies the problem: The CustomActionData-Attribute is always empty and the setup throws an exception.
My CustomAction is a C# DLL file: DemoDatumErzeugen.CA.dll
. It contains a method DatumEintragen
which modifies the configuration file. I'm trying to access the data this way:
string path = session.CustomActionData["LOCATION"];
This is where the exception is thrown. I only got the German error message, but it says something along the lines: The supplied key was not found in the dictionary
(Der angegebene Schlüssel war nicht im Wörterbuch angegeben.
).
This is how I try passing the properties from my setup-script to my custom action:
<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>
I've seen many examples where it was done the same way or at least very similar. I've tried many things but nothing seems to help like changing the value After in <Custom Action="DemoDatum.SetProperty" After="InstallFiles"/>
. CustomActionData is always zero.
I check it with: session.CustomActionData.Count
Once again I'm pretty thankful for any help or hints where I've done something wrong.
The Property
attribute value of DemoDatum.SetProperty
should be equal to the Id
attribute value of the deferred action. So, either change the property name to DemoDatum
, or change the Id
of the deferred action to DatumEintragen
.
来源:https://stackoverflow.com/questions/9564090/wix-customactiondata-is-empty-in-called-customaction