Accessing properties in a deferred action
If you try to access a property from a custom action during the Execute sequence's deferred stage, you'll find that you get an error. This is because only a finite number of properties are available here. As a workaround, you can store the value of your properties in another property called CustomActionData
and pass that to the custom action.
There are two ways to do this: from your WiX code or from inside another C# custom action. In your WiX markup, you can set a property with a custom action that has a Property
attribute that matches the custom action you want to pass the property to.
In the next example, we want to pass the MYPROPERTY
property to a custom action called myDeferredCA
. So, we create another action called SetProperty
that sets a property, also called myDeferredCA
, to the value of MYPROPERTY
.
<Property Id="MYPROPERTY" Value="my value" /> <CustomAction Id="SetProperty" Property="myDeferredCA" Value="[MYPROPERTY]" /> ...