How do I debug this type of error?
The problem file is System.Memory, Version=4.0.1.1. From what I can see, I have no references to this file in any of my projects and I've checked the dependencies of my imported nuget packages and none of them reference this file.
Why is this file being loaded? Frustratingly, the error that is thrown within an InvalidOperationException with the ReflectionTypeLoadException simply being a message. I don't have access to error being thrown as it is thrown in a DLL I don't have access to. That DLL forms part of my companies framework.
I have a very similar project that uses the same company framework DLLs which doesn't have this problem.
The Error:
Exception thrown: 'System.InvalidOperationException' in ****.dll ReflectionTypeLoadException errors: [Could not load file or assembly 'System.Memory, Version=4.0.1.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)][Could not load file or assembly 'System.Memory, Version=4.0.1.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)][Could not load file or assembly 'System.Memory, Version=4.0.1.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)][Could not load file or assembly 'System.Memory, Version=4.0.1.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)][Could not load file or assembly 'System.Memory, Version=4.0.1.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)]
The error from Fuslogvw is as follows:
*** Assembly Binder Log Entry (19/01/2021 @ 20:33:19) ***
The operation failed.
Bind result: hr = 0x80131040. No description available.
Assembly manager loaded from: C:\Windows\Microsoft.NET\Framework64\v4.0.30319\clr.dll
Running under executable C:\SfDevCluster\Data\_App\_Node_0\*******.FabricAppType_App0\********.FabricSvcPkg.Code.1.0.1\**********.FabricSvc.exe
--- A detailed error log follows.
=== Pre-bind state information ===
LOG: DisplayName = System.Memory, Version=4.0.1.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51
(Fully-specified)
LOG: Appbase = file:///C:/SfDevCluster/Data/_App/_Node_0/******.FabricAppType_App0/******.FabricSvcPkg.Code.1.0.1/
LOG: Initial PrivatePath = NULL
LOG: Dynamic Base = NULL
LOG: Cache Base = NULL
LOG: AppName = Prescriptions.Api.FabricSvc.exe
Calling assembly : (Unknown).
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\SfDevCluster\Data\_App\_Node_0\*******.FabricAppType_App0\******.FabricSvcPkg.Code.1.0.1\******.FabricSvc.exe.Config
LOG: Using host configuration file:
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework64\v4.0.30319\config\machine.config.
LOG: GAC Lookup was unsuccessful.
LOG: Attempting download of new URL file:///C:/SfDevCluster/Data/_App/_Node_0/******.FabricAppType_App0/*******.FabricSvcPkg.Code.1.0.1/System.Memory.DLL.
LOG: Assembly download was successful. Attempting setup of file: C:\SfDevCluster\Data\_App\_Node_0\*******.FabricAppType_App0\*******.FabricSvcPkg.Code.1.0.1\System.Memory.dll
LOG: Entering run-from-source setup phase.
LOG: Assembly Name is: System.Memory, Version=4.0.1.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51
WRN: Comparing the assembly name resulted in the mismatch: Revision Number
ERR: The assembly reference did not match the assembly definition found.
ERR: Run-from-source setup phase failed with hr = 0x80131040.
ERR: Failed to complete setup of assembly (hr = 0x80131040). Probing terminated.