13

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.

Yan Sklyarenko
  • 29,347
  • 24
  • 104
  • 125
Skalli
  • 2,597
  • 3
  • 25
  • 36

1 Answers1

17

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.

Yan Sklyarenko
  • 29,347
  • 24
  • 104
  • 125
  • Indeed! That was it. Thank you alot. It's easy to overlook. – Skalli Mar 05 '12 at 13:55
  • @Yan Sklyarenko I am facing a problem during the installation of my .exe created using bootstraper application.Can you please look into this SO and help me http://stackoverflow.com/questions/27151665/error-0x80070643-fatal-error-during-installation-wix – user2725407 Nov 26 '14 at 15:34