I have a WiX installer and Custom Actions project. I added C# library as reference to Custom action's project. This C# dll uses DllImport to one C++ dll. When installing I receive error: cannot load DLL mycpp.dll
: specified module not found. I added mycpp.dll
to CA project and tried using properties : embedded resource, copy to output directory - but no result. How can I make my installer find mycpp.dll
?
Asked
Active
Viewed 683 times
1

Stein Åsmul
- 39,960
- 25
- 91
- 164

Anton23
- 2,079
- 5
- 15
- 28
1 Answers
2
I've had this issue before. After reading through the MSBuild files for wix I eventually found a property that is used as a list for the dlls needed in the self-extracting package that contains the custom action dll.
in wix.ca.targets (in the sdk folder) there is a property called CustomActionContents that is used when running makesfxca.
Here's the comment for this set of msbuild targets which package your custom action dll.
<!--
==================================================================================================
PackCustomAction
Creates an MSI managed custom action package that includes the custom action assembly,
local assembly dependencies, and project content files.
[IN]
@(IntermediateAssembly) - Managed custom action assembly.
@(Content) - Project items of type Content will be included in the package.
$(CustomActionContents) - Optional space-delimited list of additional files to include.
[OUT]
$(IntermediateOutputPath)$(TargetCAFileName) - Managed custom action package with unmanaged stub.
==================================================================================================
-->
and
<!--
Items to include in the CA package:
- Reference assemblies marked CopyLocal
- Project items of type Content
- Additional items in the CustomActionContents property
-->
So it looks like you can mark your reference to the mycpp.dll as copy local and it will be automatically picked up or you can add a new property in your custom action project (probably edit the csproj and add the property) which contains the path to the dll and it will get picked up.

Brian Sutherland
- 4,698
- 14
- 16
-
I know it's been asked a while back. But can you add how does one add the `CustomActionContents` property to the WiX project in MS Visual Studio? My problem with other solutions is that I need to add a native/unmanaged DLL to my C# custom action that is used for pinvoke calls from it. But it has to be either x86 or x64 versions of the unmanaged DLL, depending on the configuration settings in VS, and I can't figure out how to do it. – c00000fd Mar 01 '22 at 09:20