I have a unit test project that is using Nunit and Fakeiteasy and targeting .net framework 4.8. Yesterday I've added few test methods that are mocking "BlobContainerClient" of Azure storage. Locally all of the unit tests are passed but when I push my code, Azure devops throws the following error:
System.IO.FileLoadException : Could not load file or assembly 'System.Threading.Tasks.Extensions, Version=4.2.0.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) System.IO.FileLoadException : Could not load file or assembly 'System.Threading.Tasks.Extensions, Version=4.2.0.0, 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)
I can see in the csProj that it's using the correct version:
<Reference Include="System.Threading.Tasks.Extensions, Version=4.2.0.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Threading.Tasks.Extensions.4.5.4\lib\net461\System.Threading.Tasks.Extensions.dll</HintPath>
</Reference>
And also in the app.config
<dependentAssembly>
<assemblyIdentity name="System.Threading.Tasks.Extensions" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.2.0.1" newVersion="4.2.0.1" />
</dependentAssembly>
When I download Azure.Storage.Blobs package it also downloaded the System.Threading.Tasks.Extensions package but version 4.5.2. I manually updated it to 4.5.4 because it was still throwing this error but still no luck.
I tried removing reference from csProj file and then added the 4.2.0.0 reference directly through "Add References" window of the project but then I started getting same error locally.
Any idea what can be wrong?