[wix-users] System Error in Custom Action when generating a binary file. The system cannot find the path specified

Christopher Painter chrpai at iswix.com
Sun Jan 1 18:39:49 PST 2017


CustomActionData has to be a property with a name that matches the name of the deferred custom action.


Custom Action set Property  name Foo   value  Bar.

Custom Action  Foo  binary some.dll  target Foo


[CustomAction]

public static ActionResult Foo( Session session )

{

   var customActionData = session[CustomActionData];

 //  customActionData now equals Foo

}

DTF has a class called that assists in serializing and deserializing multiple key value pairs into this single property.

Here's a blog article I wrote about this topic in the past.

http://blog.iswix.com/2011/10/beam-me-up-using-json-to-serialize.html


________________________________
From: wix-users <wix-users-bounces at lists.wixtoolset.org> on behalf of Anna Flyam | Landtech <anna at landtechdataservices.com>
Sent: Friday, December 30, 2016 10:57 AM
To: WiX Toolset Users Mailing List
Subject: [wix-users] System Error in Custom Action when generating a binary file. The system cannot find the path specified

My deferred Custom Action is responsible for creating and writing to a
binary file Before InstallFinalize.
When testing using hardcoded file name/path, it works, but I need to use
[file path] from the Property that I am passing to this CA.
I use session.Log to print the value of that property and it looks good,
but the file is not getting generated.
It must be something simple that I am missing. Sequence? Hope you can help.

1. Directory ID is "BIN"
Directories.wxs
<Directory Id="TARGETDIR" Name="SourceDir">
          <Directory Id="INSTALLFOLDER" Name="Apps" >
            <Directory Id ="BIN" Name="BIN" />
...
<!-- 2. Create Empty Folder. This folder will be used in my CA to create a
file-->
AppsComponents.wxs
<DirectoryRef Id="BIN" >
      <Component Id="CMP_Bin" Guid="{E005D3D9-3624-42BE-8BCB-16988453B661}"
KeyPath="yes">
        <CreateFolder />
      </Component>
   </DirectoryRef>

Product.wxs
 <!-- 3. Create Property for deferred CA-->
 <Property Id="MYFILEFULLPATHPROPERTY" Value="[BIN]MYFILE.DAT" />
  <!-- 4. CA and set property-->
 <CustomAction Id="CA_WriteBinaryFile"
                  BinaryKey="LtxCustomActionsDLL"
                  DllEntry="WriteBinaryFile"
                  Execute="deferred"
                  Impersonate="no"
                  Return="check" />

 <SetProperty Id="CA_WriteBinaryFile"

 Value="SERIALNUMBER=[SERIALNUMBER];MYFILEFULLPATHPROPERTY=[MYFILEFULLPATHPROPERTY]"
                     Sequence="execute"
                     Before="CA_WriteBinaryFile" />

<!-- 5. Schedule deferred CA-->
<InstallExecuteSequence>
      <Custom Action="CA_WriteBinaryFile" Before="InstallFinalize">NOT
Installed AND NOT REMOVE</Custom>
</InstallExecuteSequence>


[CustomAction]
public static ActionResult WriteBinaryFile(Session session)
{
...
//"C:\\APPS\\BIN\\MYFILE.DAT"

 myBinFile = session.CustomActionData["MYFILEFULLPATHPROPERTY"];


 using (BinaryWriter writer = new BinaryWriter(File.Open( myBinFile,
FileMode.Create)))
                { ...}

Error from the install log:
Action 10:25:47: CA_WriteBinaryFile.
MSI (s) (40:08) [10:25:47:498]: Executing op:
CustomActionSchedule(Action=CA_WriteBinaryFile,ActionType=3073,Source=BinaryData,Target=WriteBinaryFile,CustomActionData=SERIALNUMBER=ABC-DC;MYFILEFULLPATHPROPERTY=[BIN]MYFILE.DAT)
MSI (s) (40:64) [10:25:47:701]: Invoking remote custom action. DLL:
C:\WINDOWS\Installer\MSI7AAF.tmp, Entrypoint: WriteBinaryFile
MSI (s) (40:B8) [10:25:47:701]: Generating random cookie.
MSI (s) (40:B8) [10:25:47:701]: Created Custom Action Server with PID 3508
(0xDB4).
MSI (s) (40:EC) [10:25:49:186]: Running as a service.
MSI (s) (40:EC) [10:25:49:201]: Hello, I'm your 32bit Elevated Non-remapped
custom action server.
SFXCA: Extracting custom action to temporary directory:
C:\WINDOWS\Installer\MSI7AAF.tmp-\
SFXCA: Binding to CLR version v4.0.30319
Calling custom action
LtxCustomActions!LtxCustomActions.CustomActions.WriteBinaryFile
Started CA WriteBinaryFile
Serial Number:ABC-DC
Number of Users = 5
Our Binary file  = C:\Apps\BIN\MYFILE.DAT <<< session.Log

MSI (s) (40:08) [10:25:55:717]: Executing op:
End(Checksum=0,ProgressTotalHDWord=0,ProgressTotalLDWord=1471642952)

*MSI (s) (40:08) [10:25:55:826]: Note: 1: 2265 2:  3: -2147287035  <<<<<
Error: Cannot find the path specified*

MSI (s) (40:08) [10:25:55:826]: User policy value 'DisableRollback' is 0
MSI (s) (40:08) [10:25:55:826]: Machine policy value 'DisableRollback' is 0
MSI (s) (40:08) [10:25:55:826]: Note: 1: 2265 2:  3: -2147287035
Action 10:25:55: RollbackCleanup. Removing backup files
RollbackCleanup: File: C:\Config.Msi\279d6517.rbf
RollbackCleanup: File: C:\Config.Msi\279d6518.rbf
MSI (s) (40:08) [10:25:55:873]: Note: 1: 2318 2:
MSI (s) (40:08) [10:25:55:873]: Note: 1: 2318 2:
MSI (s) (40:08) [10:25:55:967]: Calling SRSetRestorePoint API.
dwRestorePtType: 0, dwEventType: 103, llSequenceNumber: 28, szDescription:
"".
MSI (s) (40:08) [10:25:55:967]: The call to SRSetRestorePoint API
succeeded. Returned status: 0.
MSI (s) (40:08) [10:25:55:967]: Unlocking Server
MSI (s) (40:08) [10:25:56:077]: PROPERTY CHANGE: Deleting UpdateStarted
property. Its current value is '1'.
Action ended 10:25:56: InstallFinalize. Return value 1.



*Anna Flyam*
*Software Engineer*
*Landtech Data Services*

[image: Landtech] <http://www.landtechdata.com/index.php>
Welcome to Landtech | Customized Title Settlement Software<http://www.landtechdata.com/index.php>
www.landtechdata.com
Founded in September 1981, Landtech Data Services is the first Real Estate Settlement Software built for PC. Seamlessly integrated with dozens of Industry Standard ...



Main O: (800)-835-1523 <%28800%294835-1523> | F: (561)-798-818
<%28561%294798-0818> |  E: Anna at Landtechdataservices.com
<Anna at landtechdataservices.com>
1460 Royal Palm Beach Blvd,
Royal Palm Beach, Florida 33411
www.landtechdata.com<http://www.landtechdata.com>
Welcome to Landtech | Customized Title Settlement Software<http://www.landtechdata.com/>
www.landtechdata.com
Founded in September 1981, Landtech Data Services is the first Real Estate Settlement Software built for PC. Seamlessly integrated with dozens of Industry Standard ...




____________________________________________________________________
WiX Toolset Users Mailing List provided by FireGiant http://www.firegiant.com/
WiX Support | WiX Experts and Resources from FireGiant<http://www.firegiant.com/>
www.firegiant.com
WiX Support | Installation, Development, Deployment | WiX Experts and Resources from FireGiant





More information about the wix-users mailing list