-
-
Notifications
You must be signed in to change notification settings - Fork 838
Open
Labels
Description
Describe the Bug
Unit tests using Moq fail with runtime error after updating Moq to latest version. See details below.
Steps to Reproduce
- Update Moq ro 4.20.72 in a .NET Framework based unit test project
- Run unit tests
Expected Behavior
The unit tests run.
Exception with Stack Trace
Unit tests fail with error
Initialization method [...] threw exception. 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).
at Moq.Async.AwaitableFactory..cctor()
Version Info
- Moq 4.20.72
- System.Threading.Tasks.Extensions 4.6.3
- .Net Framework 4.8.0
- Visual Studio 2026
Additional Info
- It worked with an earlier version of Moq.
- "Auto-generate binding redirects" is enabled in the unit test project.
Adding binding redirects to app.config, such as
<dependentAssembly>
<assemblyIdentity name="System.Threading.Tasks.Extensions" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-999.999.999.999" newVersion="4.6.3.0"/>
</dependentAssembly>or
<dependentAssembly>
<assemblyIdentity name="System.Threading.Tasks.Extensions" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-999.999.999.999" newVersion="4.2.0.1"/>
</dependentAssembly>changes nothing.
This seems to be a recurring issue that is repeatedly being blamed on Microsoft and users of Moq, when the common denominator is always Moq. Also, in an earlier report of this issue, it was stated by the developer that Moq deliberately uses an old version of System.Threading.Tasks.Extensions to avoid binding redirect issues, which is clearly not the case.
