Reputation: 26936
Can not set a property value using Session.CustomActionData.
if (s.CustomActionData.ContainsKey(PropertyName0))
s.CustomActionData[PropertyName0] = "1";
else
s.CustomActionData.Add(PropertyName0, "1");
Although this code works, when the custom action ends, the properties remain unchanged. So how do I set the property value? I need to set the property value in one custom action and read it in another.
Upvotes: 1
Views: 2787
Reputation: 166
It is not clear what you are doing. Only few properties are available in the deferred custom action. Are you trying to pass data to a deferred custom action?
You can write an immediate custom action to write properties and then pass these to a deferred custom action if you need this at run time.
Here is an example of an immediate CA
[CustomAction]
public static ActionResult ImmediateCA(Session session)
{
CustomActionData data = new CustomActionData();
data["property1"] = "abc";
data["property2"] = "def";
session["myDeferredCAData"] = data.ToString();
return ActionResult.Success;
}
[CustomAction]
public static ActionResult myDeferredCA(Session session)
{
CustomActionData data = session.CustomActionData;
string property1 = data["property1"];
return ActionResult.Success;
}
This solution is proposed by Nick Ramirez
Upvotes: 2
Reputation: 26936
It is impossible to set a property in a deferred custom action. http://msdn.microsoft.com/en-us/library/aa370543(v=VS.85).aspx
Upvotes: 0
Reputation: 279
Are you using managed code for this? I know that I've had trouble with getting C++ CAs to take in a property and update the property in one CA. In the past I've written to the registry in one CA and read from it into a property in another to get around this problem.
Upvotes: 1