0

I'm creating a basic MSI installshield 2014 project. I've added a custom action which calls a public method present in a managed .Net assembly (MyCSharpAssembly.dll). Now my managed dll in turn calls a method present in an unamanged/native assembly (MyUnamanagedCPlusPlusAssembly.dll) written in C++. I used DllImport methodology to load the native assembly at run time.

I added the native dlls into support files ( [SUPPORTDIR]) based on the accepted answer of this thread. I also see those native assemblies getting copied in the temporary working directory of installshield when I run the MSI output. Still, it doesn't work? When installer runs I simply get following error in the logs-

Failed to load assembly. Dll not found.

This essentially means CLR/.net run-time is unable to see the native assembly dlls at run time. Does anyone have any idea on to specifically load native dll dependencies during installation process?

Community
  • 1
  • 1
RBT
  • 24,161
  • 21
  • 159
  • 240
  • Perhaps you have to use LoadLibrary with the full paths to get these DLLs loaded. Or perhaps they are missing runtime dependencies. – David Heffernan Jan 21 '17 at 08:07
  • I agree with verifying the paths that the DllImport is loading from, say with [ProcMon](https://technet.microsoft.com/en-us/sysinternals/processmonitor.aspx), and would suggest examining the state of the system, say by pausing the install with a MessageBox just before or after the failure. Add anything useful you find to your question. Please also clarify the locations of each relevant DLL - including MyCSharpAssembly.dll - whether SUPPORTDIR, binary table, or installed somewhere. – Michael Urman Jan 21 '17 at 14:34
  • I added some log into my C# code which in turn calls the API in unmanaged library. I ran code `Directory.GetCurrentDirectory`. This tells me that my managed code is being invoked from `C:\Windows\SysWow64` which is the same path where `msiexec.exe` resides. If I copy my C++ assemblies at this path then my p/invoke calls start to work but this is a very dirty solution because then I've to delete it also manually as installshield doesn't know about it. There should be a way to tell installshield that please load my unamanged binaries from [SUPPORTDIR] instead. – RBT Jan 22 '17 at 09:33
  • Does this answer your question? [How can I specify a \[DllImport\] path at runtime?](https://stackoverflow.com/questions/8836093/how-can-i-specify-a-dllimport-path-at-runtime) – Yola Dec 12 '20 at 02:26

0 Answers0