1

I've implemented a .net DLL (in c#) which gets loaded by the OS (basically it is a ADFS MFA Adapter). This DLL references the assembly 'Microsoft.IdentityServer.Web' which is present in the OS. This works fine on Windows Server 2012 (ADFS 3.0).

This Fails on Windows Server 2016 (ADFS 4.0) as it has a newer version of the assembly 'Microsoft.IdentityServer.Web' (same public key though). How do I handle this scenario ?

  • The first thing comes to my mind is build platform specific version of my DLL (one for each OS Win2012 & Win2016) referencing the appropriate assembly version. Install the DLL based on which OS it is being installed. This will have some build and install overhead.

Is there a simpler way to do this ?

  • Some way for me to reference both the version of the Assemblies in my DLL's config file. When my DLL is loaded it looks for which version of assembly is present in GAC and loads the right version. (Fortunately there is only version of the dependent assembly 'Microsoft.IdentityServer.Web' in the GAC).
  • I noticed some approach to add some hooking code in my DLL which gets called before Assemblies Load. Then Load the right assembly present in GAC. (AppDomain…AssemblyResolve approach). I tried this but did not have much luck to hook into the code when my DLL loads.
Ped7g
  • 16,236
  • 3
  • 26
  • 63
Feru
  • 1,151
  • 2
  • 12
  • 23
  • @HansPassant Appreciate the response. I'm currently looking into the config approach of binding redirect. Do you know if this approach can dynamically check and load the right dependency of reference assembly on the target system ? – Feru Jan 19 '18 at 15:11

1 Answers1

0

I think have solved a similar problem with a wrapper for windows DLLs by dynamically checking which parameters are there.

Issues compiling in Windows 10

It is probably not a good solution, but a better one considering that the alternative would be to pre-compile a dll and dynamically swapping that, especially in terms of using a VCS.

geraphl
  • 305
  • 4
  • 10