Side by side in dll

414 Views Asked by At

I have the following situation:

  • An executable developed in C# links a managed DLL which calls another third party DLL (loaded as side by side). The exe doesn't use directly any object from the third party DLL.

The relation between the components is:

EXE -->> myDLL >> 3rdPartyDLL

I would like to set a reference of the 3rd party DLL only in myDLL.manifest (compiling it with mt.exe) like that: myDLL.manifest

<?xml version="1.0" encoding="utf-8"?>
<asmv1:assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1" xmlns:asmv1="urn:schemas-microsoft-com:asm.v1" xmlns:asmv2="urn:schemas-microsoft-com:asm.v2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<assemblyIdentity version="1.0.0.0" name="myDLL"/>
  <dependency>
   <dependentAssembly>
      <assemblyIdentity type="win32" name="ThirdPartyDLL" version="1.0.0.0"/>
   </dependentAssembly>
  </dependency>
<file name ="myDLL.dll"/>
</asmv1:assembly>

But when I launch the EXE it raises an exception, because it doesn't find the 3partyDLL. It works only if I insert also into the EXE.manifest the dependency to the 3rdPartyDLL.

But in this case everytime the third partyDLL changes the version (also for small fixes) I need to recompile the EXE to embed the manifest into it.

I tried to look deeply for some practical example with such scenario, but I didn't find anything. Is there any reference or practical example about it?

1

There are 1 best solutions below

1
On

Where is the 3rdPartyDLL located on your system? Is it in the same folder as that of the exe or in some other path? Instead of adding the dependency of the 3rdPartyDLL in the EXE.manifest make sure the 3rdPartyDLL is in the same folder as that of the exe.