I am developing a C# (.NetFramework 4.8) plugin to be loaded in another (proprietary closed source) software. For this I have to link my plugin to a dll of the other software, here called main.dll.
Unfortunatly the other software comes with different versions of main.dll: 1.2.0.33 and 2.0.11.0. When I now link my addin to one of those dlls and try to load it while being in the other, the program fails with something like System.IO.FileNotFoundException: The file or assembly "main, Version=1.2.0.33, Culture=neutral, PublicKeyToken=abcabcabcabcabc" or a dependency is not found.
My question is, if there is a way to build only one dll, which is able to use both versions of the main.dll?
Please note the following:
All functions I need of this dll, have exactly the same interface – all I currently have to do is to replace this dll before compiling.
The plugin is meant to be used by other users, which cannot change the way the main software is run, so placing binding redirection files into the directory from which the main executable is run is not possible.
However, I am generally able to run command-line commands while loading my plugin into the other software.
I can obviously ship two different plugin versions and determine the needed version before loading, but this feels kind of inelegant.
Thank you for your help!