Run two versions of the same unmanaged dll (referenced by C#-app)


I have two softwares, written in C#, using the same third-party dll to get telephony-capabilities.


When I deploy a new version of one of these softwares, I also deploy a new version of the dll. This one overwrites the references to the older dll, causing my other software to stop working, since the new dll isn’t backwards compatible.

Attempted solutions

  • Deploy the new software with a registration-free version of the dll.
    This doesn’t work since the dll doesn’t have a strong name. Result from sn:

C:Program Files (x86)Microsoft SDKsWindowsv8.0AbinNETFX 4.0 Tools>sn.exe -e “theDll.dll” key

Microsoft (R) .NET Framework Strong Name Utility Version 4.0.30319.17929
Copyright (c) Microsoft Corporation. All rights reserved.

theDll.dll does not represent a strongly named assembly

  • Ask the vendor for a strongly named version

This resulted in a “huh?”. The dll works well however, so I don’t want to look for a new vendor if I dont really have to.

  • Give the dll a strong name using ildasm:

C:Program Files (x86)Microsoft SDKsWindowsv8.0AbinNETFX 4.0 Tools>ildasm.exe “theDll.dll” /

error : ‘theDll.dll’ has no valid CLR header and cannot be disassembled

Which seems to imply that the dll is unmanaged, and thus not possible to strongly name (if I’m not mistaken).

  • Use SetDllDirectory and LoadLibrary to load the correct version of the dll.
    This seems to kinda work, at least I can load the correct dll from a specified place without registering it. This seems like a rather involved way to do it though.


  • Has anyone done this the “LoadLibrary”-way and can verify that it works well for a dll where you need to instantiate some classes?

  • Does anyone have a better solution?

Source: dll

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.