Problem:- Dll mismatches.
ArcGIS Pro version 3.1 contains the DLL System.ServiceModel.Primitives Version=220.127.116.11 in its' bin folder.
My solution contains an add-in that relies on 4 projects also in the same solution, all are targeting .NET 6.0. One of those 4 projects contains a package that relies on System.ServiceModel.Primitves Version 18.104.22.168. Now when I build the solution in Visual studio 2022 I get no errors, no warning.
When I run it however, and ArcGIS Pro starts loading, I get an exception in the add-in initialization module.
TypeLoadException: Could not load type 'System.ServiceModel.DuplexChannelFactory`1' from assembly 'System.ServiceModel.Primitives, Version=22.214.171.124, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.
None of my projects is loading up this assembly version, I checked the Deps.Json thoroughly, and there it is simply not there, neither is it in the output folder, only the correct version.
I went ahead and copied version 6.0 to the bin folder of ArcGIS Pro, and the issue was gone, I brought back version 4.9 to the bin folder, the problem returns.
I tried using Binding redirects in the projects app config, I tried using assembly loading techniques when the code enters the add in module to load the correct dll, and nothing seems to resolve this issue.
I have asked this question on StackOverflow and placed a bounty, and no luck, so I decided to move the question here, since this issue seems more related to ArcGIS Pro. I have the projects all posted in this link https://stackoverflow.com/questions/77888984/nuget-package-is-using-a-local-version-of-a-dll-instead-of-the-on-that-comes-wit?noredirect=1#comment137389207_77888984