To reiterate what Phil said earlier, you need two custom actions. CustomActionA 
will run in immediate mode and be scheduled just before CustomActionB which 
will run in deferred mode. The purpose of CustomActionA is to get all the data 
needed by CustomActionB.

CustomActionA will want to create a CustomActionData object and add all the 
data needed by CustomActionB. When all the data is captured you then want to 
call session.DoAction("CustomActionB", customActionData).

CustomActionB will then access the data added to the CustomActionData object 
above using the session.CustomActionData["id"] syntax.

Example:

public class CustomActionExample
{
    private const string INSTALLDIR = "INSTALLDIR";

    [CustomAction]
    public static ActionResult CustomActionA(Session session)
    {
        var customActionData = new CustomActionData();
        customActionData.Add(INSTALLDIR, session[INSTALLDIR]);
        session.DoAction("CustomActionB", customActionData);
        return ActionResult.Success;
    }

    [CustomAction]
    public static ActionResult CustomActionB(Session session)
    {
        var installDir = session.CustomActionData[INSTALLDIR];
        // use installDir here...
    }
}

Note: I wrote the example from memory... There could be errors...

Edwin G. Castro
Software Developer - Staff
Electronic Banking Services
Fiserv
Office: 503-746-0643
Fax: 503-617-0291
www.fiserv.com
Please consider the environment before printing this e-mail

> -----Original Message-----
> From: Alexander Volkov [mailto:volkov1...@gmail.com]
> Sent: Tuesday, February 23, 2010 4:24 PM
> To: General discussion for Windows Installer XML toolset.
> Subject: Re: [WiX-users] Triggering a Custom Action ONLY When All Files
> Have Been Deployed
> 
> Thank you, Phil, I think I'm much close now due to your guidance.
> May be you can guide me a bit further.
> 
> I use
> *session.CustomActionData["INSTALLDIR"]*
> to access this session property. However, I get this exception:
> 
> Exception thrown by custom action:
> System.Reflection.TargetInvocationException: Exception has been thrown
> by
> the target of an invocation. --->
> System.Collections.Generic.KeyNotFoundException: *The given key was not
> present in the dictionary.*
>   at System.ThrowHelper.ThrowKeyNotFoundException()
>   at System.Collections.Generic.Dictionary`2.get_Item(TKey key)
>   at
> Microsoft.Deployment.WindowsInstaller.CustomActionData.get_Item(String
> key)
>   at ReportsInstaller.CustomActions.PostInstall(Session session)
> 
> What would be my further step?
> 
> Thank you so much,
> Alexander
> 
> On 23 February 2010 16:02, Wilson, Phil <phil.wil...@invensys.com>
> wrote:
> > That's DTF telling you that the session isn't available when
> deferred. I
> assume DTF has a CustomActionData mechanism for passing property values
> into
> your deferred custom action.
> >
> > Phil Wilson
> >
> >
> >
> > -----Original Message-----
> > From: Alexander Volkov [mailto:volkov1...@gmail.com]
> > Sent: Tuesday, February 23, 2010 3:49 PM
> > To: General discussion for Windows Installer XML toolset.
> > Subject: Re: [WiX-users] Triggering a Custom Action ONLY When All
> Files
> Have Been Deployed
> >
> > Thank you very much for your prompt response, Phil.
> > The thing is I pass some arguments into the custom action, and if I
> > use "deferred" the installation crashes and gets rolled back.The
> > Exception is "Cannot access session details from a non-immediate
> > custom action"
> >
> > Any input?
> >
> > Thank you very much,
> > Alexander
> >
> -----------------------------------------------------------------------
> -------
> Download Intel&#174; Parallel Studio Eval
> Try the new software tools for yourself. Speed compiling, find bugs
> proactively, and fine-tune applications for parallel performance.
> See why Intel Parallel Studio got high marks during beta.
> http://p.sf.net/sfu/intel-sw-dev
> _______________________________________________
> WiX-users mailing list
> WiX-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/wix-users
------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
WiX-users mailing list
WiX-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wix-users

Reply via email to