0

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?

Ask
  • 3,076
  • 6
  • 30
  • 63
  • I've no clue. I don't really understand why you're referring to 4.2.* and also 4.5.*, but it sounds like it might be related to "The located assembly's manifest definition does not match the assembly reference." I'm so far not expecting a FakeItEasy cause, but including the full exception output may help confirm or deny… – Blair Conrad Mar 02 '22 at 16:23
  • Oh, are you using FakeItEasy.Extensions.ValueTask? What version of it (and FakeItEasy, if we still suspect FIE is a factor)? – Blair Conrad Mar 02 '22 at 16:30
  • You have a project that references `System.Threading.Tasks.Extensions` 4.2.* explicitly, while some of your other dependencies depend on 4.5.*.. You should update this project to reference 4.5.x instead, it should resolve the problem. As far as I can tell, the problem has nothing to do with FakeItEasy. – Thomas Levesque Mar 03 '22 at 07:56

1 Answers1

0

Try using assembly version, instead of NuGet package version

Try to use 4.2.0.1 assembly version in App.config

enter image description here

Pratik Somaiya
  • 695
  • 5
  • 18