Bug #110871 Could not load file or assembly 'System.Threading.Tasks.Extensions....
Submitted: 28 Apr 2023 22:20 Modified: 2 Jun 2023 12:46
Reporter: Anthony van Orizande Email Updates:
Status: No Feedback Impact on me:
None 
Category:Connector / NET Severity:S3 (Non-critical)
Version:8.0.33 OS:Windows (Windows 2016)
Assigned to: MySQL Verification Team CPU Architecture:x86

[28 Apr 2023 22:20] Anthony van Orizande
Description:
My application works correctly with the .Net Connector 8.0.32 but when I install the 8.0.33 version of the connector me and my users immediately encounter the following error.  Reverting to the 8.0.32 connector resolves the issue.

System.IO.FileNotFoundException: 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 system cannot find the file specified. at MySql.Data.MySqlClient.MySqlConnection.BeginTransaction()

Reproduced against MySQL Server versions 8.0.32 and 5.7.21-log

How to repeat:
Note: This is part of a much larger 3rd party application so please let me know if I need to create a sample application to reproduce this error.
[2 May 2023 12:46] MySQL Verification Team
Hello Anthony,

Thank you for the bug report.
Could you please share test case(sample project, etc. - please make it as private if you prefer) to reproduce this issue at our end? Thanks.

Regards,
Ashwini Patil
[3 Jun 2023 1:00] Bugs System
No feedback was provided for this bug for over a month, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
[24 Oct 2023 15:54] Adam Latchem
Restore the .net48 package and its dependencies into e.g. C:\. Then these three lines of PowerShell script reproduce the issue:

$a = [System.Reflection.Assembly]::LoadFile("C:\MySql.Data.dll")
$a.getTypes()
$e.Exception.InnerException.LoaderExceptions[64]

The result is:

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 system cannot find the file specified.

The reason is the NuGet package is broken for .net48 due to the System.Memory and CompilerServices dependencies of Google.Protobuf not matching the versions in the NuGet spec. (just enable the Fusion log to see it).

This remains broken also in 8.1.0.0. It would be useful to get it fixed so the NuGet package could be used as is. If you don't like this test case (it was the minimal repro I could find and does not need a compiler) it is possible to get the error using any type in MySql.Data based on the Protobuf dll, it just requires more code, e.g. open a connection and enlist a transaction was where I personally found it. The enumeration of types is also done in a codebase I work on also causing it.
[24 Oct 2023 16:07] Adam Latchem
Sorry four lines of PowerShell:

$a = [System.Reflection.Assembly]::LoadFile("C:\MySql.Data.dll")
$a.getTypes()
$e = $Error[0]
$e.Exception.InnerException.LoaderExceptions[64]
[18 Jan 15:07] Adam Latchem
C# Reproduction of dependency issue

Attachment: MySQLDependency.zip (application/zip, text), 6.92 KiB.

[18 Jan 15:08] Adam Latchem
I've also now uploaded a C# example with a Readme explaining it - see MySQLDependency.zip