[wix-users] How to store a file from Binary Table in a Custom Action

turik88 at yandex.ru turik88 at yandex.ru
Sun May 20 05:19:23 PDT 2018


I want to store a file from Binary table to temp location in Custom Action. I have two Custom actions, first is 'immediate', another one is 'deferred'.
When during run of the 'immediate' custom action I invoke Microsoft.Deployment.WindowsInstaller.Record.GetStream method, it does not save the file.

[CustomAction]
public static ActionResult ImmediateAction(Session session)
{
    try
    {
        View view = db.OpenView("SELECT Name, Data FROM Binary");
        view.Execute();

        foreach (Record row in view)
        {
            row.GetStream("Data", Path.Combine(Environment.GetEnvironmentVariable("temp"), row.GetString("Name"));
        }

        return ActionResult.Success;
    }
    catch (Exception ex)
    {
        session.Log(ex.Message);
        return ActionResult.Failure;
    }
    finally
    {
        db.Close();
    }
}

The Custom Action works without errors, but the file does not get being created.

In the InstallExecuteSequence the Custom Action described like:

    <InstallExecuteSequence>
       <Custom Action="ImmediateAction"
             Before="DeferredAction">
          NOT Installed
        </Custom>

        <Custom Action="DeferredAction"
             After="InstallInitialize">
          NOT Installed
        </Custom>
   </InstallExecuteSequence>

>From the 'deferred' custom action I am not able to get the db view, which is expected. 
And, I am not able to pass the File's binary data from 'immediate' to 'deferred' Custom Action since System.IO.Stream class does not support serialization.

How can I save a file from Binary table in a Custom Action?


More information about the wix-users mailing list