I'm writing a Excel COM plugin with C# and .Net 4.8. The plugin use Utf8JsonReader from System.Text.Json package. This package need System.Memory as dependency, and Memory need System.Runtime.CompilerServices.Unsafe as dependency so Nuget install Unsafe package 4.0.6.0 for me. When come to run time, Excel successfully load my MyDll plugin, but Unsafe.dll not. .Net Framework didn't read MyDll.dll.config which contains bindingRedirect information, and used version 4.0.4.1 from Memory.dll's Manifest. According to exception's fusionLog, .Net find the dll file, but get a version mismatch error.
After some google, somebody says I need a EXCEL.exe.config near EXCEL.EXE, instead of MyDll.dll.config near MyDll.dll. It worked, but not a good solution for me, is there any good way to define bindingRedirect for dll plugin without "hack into Excel's installation"?
System.Memory.dll's Manifest:
Exception's fusionLog, not Unsafe Dll, but same problem: