Problem with dependency that depends on older version of other dependency + GAC
We have a library that depends on System.Memory 4.5.5 (assembly version: 220.127.116.11) and at the same time have dependency to System.Runtime.CompilerServices.Unsafe 4.7.1 (assembly version: 18.104.22.168). Both of them are in GAC.
Unfortunately when we run that library in LINQPad and use AsSpan() method it tries to load System.Runtime.CompilerServices.Unsafe with assembly version: 22.214.171.124. And it result in a crash with
Could not load file or assembly 'System.Runtime.CompilerServices.Unsafe, Version=126.96.36.199, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified..
I've tried implementing AppDomain.AssemblyResolve event and it seems to help in standard .NET executable but not in LINQPad.
I know that adding the assembly redirect will fix it. But I'm looking for a solution that won't require to add that redirect because this library will be used by multiple clients in a lot of LINQPad scripts.So ensuring such manual step in all those places is not feasible.