views:

37

answers:

1

I am interested in the best practice of the following scenario. I have a CustomAction method that hits a web service and returns some information that I use to populate a combo box. Later in the install process in another CustomAction method, I need to access some of the meta data returned from that first web service call.

In the first method, I create a List that is a public static member of my CustomAction class. In my second method when I access the list its empty.

My thoughts were to serialize it using xaml serialization into a session variable then deserialize it in my second method.

Am I way off here? Is there a better way?

A: 

I will assume that your second custom action is making configuration changes to the machine and running in the execute sequence as deferred with no impersonation. This means it can only access the CustomActionData property.

This means your first custom action will have to serialize the CustomActionData property for the second one to deserialize. Now the CustomActionData is a Key:Value collection and what you do with it ( including have a Key with a Value that is yet another serialized datatype ) is completely up to you.

Be sure to read the DTF documentation to understand how to use the CustomActionData type and members off the Session class to your advantage.

Christopher Painter
No, it is not running as deferred. It is another action called several dialogs later in the sequence. I can access the session object just fine and its still fully populated. I just don't know how to store an object in it. I only have stored strings.
KnightsArmy
What does the second custom action do? BTW, a serialized object is an XML fragment which is nothing but a string with a lot of markup. There is no way to pass an actual object because you are crossing from one managed application domain back to unmanaged code and then back into a new managed application domain.
Christopher Painter
That is what I assumed regarding the managed vs unmanaged. It's nice to see it spelled out though. I was just making sure that there wasn't a trick I didn't know about.I have a combo box populated with an identity value and description from a list of custom Locations. The user picks the location in the combo box. Several dialogs later I need to present the user with default options from the Location they selected.
KnightsArmy
I don't know anything about your install or it's UI but my gut tells me it might flow smoother if the two dialogs were closer together or even integrated in some way since there is a connection between the two from a business rule perspective.
Christopher Painter
Agreed. It is a little disjointed right now.
KnightsArmy