mikeL
Posts: 3
Joined: Thu Jun 28, 2018 5:03 pm

Custom action not in same folder as temporary files

I have a custom action which is a "Call Function From Attached Native DLL".
The "Attached DLL" needs to have dependencies in the same folder as the DLL.

So checking out previous post about this, I find out the solution was to add temporary files.
Running the built installer throws an error and after looking the log files, it seems the installer doesn't place the temporary files in the same folder as the custom action... Why ?

I have attached screenshots which shows the problem.
The DLL causing the error is "sntl_adminapi_windows.dll".

Note: As you can see in the provided screenshot, the temporary folder created for the custom action contains the references from the project which I never specified in the custom action. This means the installer automatically resolve some of the dependencies and included them in the folder that it has created.
Attachments
extractTempFilesLog.PNG
extractTempFilesLog.PNG (135.31 KiB) Viewed 3936 times
customActionErrorLog.PNG
customActionErrorLog.PNG (57.15 KiB) Viewed 3936 times
customActionTempFolder.PNG
customActionTempFolder.PNG (76.88 KiB) Viewed 3937 times
Daniel
Posts: 8238
Joined: Mon Apr 02, 2012 1:11 pm
Contact: Website

Re: Custom action not in same folder as temporary files

Hello Mike and welcome to our forums,

I tested the scenario and replicated the behavior. It seems that Windows Installer creates indeed a temporary folder at install time for each "Call Function From Attached Native DLL" custom action you add into your setup project. Under this temporary folder are extracted the entry point DLL and only its references added explicitly in the WiX custom action project within Visual Studio and that have the Copy Local flag set to True.
screen.jpg
screen.jpg (113.18 KiB) Viewed 3902 times
As a solution, to achieve what you need you should explicitly add as a reference to your custom action project in Visual Studio all the DLL files required by your custom action (including the secondary references and so on). And set their copy local flag to true. Can you please try this approach and let us know if this is suitable for you?

All the best,
Daniel
Daniel Radu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
mikeL
Posts: 3
Joined: Thu Jun 28, 2018 5:03 pm

Re: Custom action not in same folder as temporary files

Hello Daniel,

This is exactly my problem.
The library referenced is unmanged C++ Code which you cannot add to reference in a project.
The wrapper however does get copied to the proper directory.

So what can I do with unmanaged code to get copied in the same directory ?
Is there any property I can use ?
Daniel
Posts: 8238
Joined: Mon Apr 02, 2012 1:11 pm
Contact: Website

Re: Custom action not in same folder as temporary files

Hello Mike,

In this case I am afraid the only scenario I can think of will be like this:

1. add the unmanaged DLL as temporary file in "Files and Folders" page of your setup project; double clicking on it you will see the temp file has a property assigned in the Edit Temporary File dialog (e.g. AI_UNMANAGED.DLL)

2. add functionality into your WiX custom action code to copy the temporary extracted unmanaged DLL into the custom action extraction folder

3. call your WiX custom action DLL using a "Call function from attached native DLL"

You can access the unmanaged temporary extracted DLL by its assigned property (i.e. session["AI_UNMANAGED.DLL"]). Also the temp directory where the custom action extracts its target DLL files could be accessed by using the "Directory.GetCurrentDirectory Method ()".

This is the only workaround solution I could think of. Hope this helps somehow.

All the best,
Daniel
Daniel Radu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
mikeL
Posts: 3
Joined: Thu Jun 28, 2018 5:03 pm

Re: Custom action not in same folder as temporary files

Hello Daniel,

The suggested work around did work.

Would there by any improvements in the near future to avoid that kind of work around ?
Daniel
Posts: 8238
Joined: Mon Apr 02, 2012 1:11 pm
Contact: Website

Re: Custom action not in same folder as temporary files

Hello Mike,

I am very sorry but such kind of improvements are almost impossible to be implemented. This is because, after further investigating this scenario we found out that the temporary subfolder created under TEMP location is not created by the Windows Installer service, but by the WiX DLL itself. The WiX .CA.DLL is a self extracting DLL which extracts its target entry point DLL and all of its dependency DLLs under the related random named sunbfolder in TEMP.

Considering all of the above I cannot make you any promise for such kind of improvements.

Thank you for your understanding.

All the best,
Daniel
Daniel Radu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Common Problems”