Bug #101095 ASP.NET build issues starting with MySQL .NET Connector 8.0.20 and 8.0.21
Submitted: 8 Oct 2020 18:51 Modified: 10 Aug 2022 21:16
Reporter: Joey Newell Email Updates:
Status: Can't repeat Impact on me:
None 
Category:Connector / NET Severity:S1 (Critical)
Version:8.0.20,8.0.21 OS:Windows
Assigned to: CPU Architecture:Any

[8 Oct 2020 18:51] Joey Newell
Description:
Starting with the MySQL .NET Connector 8.0.20 and 8.0.21 we are no longer able to compile clean builds of our Visual Studio 2019 ASP.NET applications (targeting Version 4.8 framework). The below errors/warning are displayed. Downgrading to 8.0.19 or earlier resolves the issue so we are unclear what changed with 8.0.20 that introduced this issue not allowing us to get clean builds.

1>------ Build started: Project: WebApplication1, Configuration: Debug Any CPU ------
1>  No way to resolve conflict between "System.Buffers, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51" and "System.Buffers, Version=4.0.2.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51". Choosing "System.Buffers, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51" arbitrarily.
1>  Consider app.config remapping of assembly "System.Buffers, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51" from Version "4.0.2.0" [] to Version "4.0.3.0" [C:\Program Files (x86)\MySQL\Connector NET 8.0\Assemblies\v4.5.2\System.Buffers.dll] to solve conflict and get rid of warning.
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets(2084,5): warning MSB3247: Found conflicts between different versions of the same dependent assembly. In Visual Studio, double-click this warning (or select it and press Enter) to fix the conflicts; otherwise, add the following binding redirects to the "runtime" node in the application configuration file: <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"><dependentAssembly><assemblyIdentity name="System.Buffers" culture="neutral" publicKeyToken="cc7b13ffcd2ddd51" /><bindingRedirect oldVersion="0.0.0.0-4.0.3.0" newVersion="4.0.3.0" /></dependentAssembly></assemblyBinding>
1>  WebApplication1 -> C:\Projects\WebApplication1\bin\WebApplication1.dll
========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========

Severity	Code	Description	Project	File	Line	Suppression State
Warning		Found conflicts between different versions of the same dependent assembly. In Visual Studio, double-click this warning (or select it and press Enter) to fix the conflicts; otherwise, add the following binding redirects to the "runtime" node in the application configuration file: <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"><dependentAssembly><assemblyIdentity name="System.Buffers" culture="neutral" publicKeyToken="cc7b13ffcd2ddd51" /><bindingRedirect oldVersion="0.0.0.0-4.0.3.0" newVersion="4.0.3.0" /></dependentAssembly></assemblyBinding>	WebApplication1			

How to repeat:
1) Create a new ASP.NET project in Visual Studio 2019
2) Add the MySQL .NET Connector 8.0.20 or 8.0.21 as a reference
3) Build application
4) Build errors occur as indicated above

Note: Downgrading to 8.0.19 or earlier resolves the issue.

Suggested fix:
Resolve build errors/warnings where .NET project will build cleanly and clarify what changed from 8.0.19 that introduced this issue in the new versions for the MySQL .NET Connector.
[9 Oct 2020 3:41] Bradley Grainger
> Downgrading to 8.0.19 or earlier resolves the issue so we are unclear what changed with 8.0.20 that introduced this issue not allowing us to get clean builds.

Comparing https://www.nuget.org/packages/MySql.Data/8.0.19 and https://www.nuget.org/packages/MySql.Data/8.0.20 you can see that the .NET 4.8 version of the library added a dependency on System.Buffers (>= 4.5.0).

The compiler warning tells you how to fix the problem (and possibly avoid assembly binding failures at runtime):

add the following binding redirects to the "runtime" node in the application configuration file: <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"><dependentAssembly><assemblyIdentity name="System.Buffers" culture="neutral" publicKeyToken="cc7b13ffcd2ddd51" /><bindingRedirect oldVersion="0.0.0.0-4.0.3.0" newVersion="4.0.3.0" /></dependentAssembly></assemblyBinding>
[9 Oct 2020 12:48] MySQL Verification Team
Hello Joey Newell,

Thank you for the report and feedback!

regards,
Umesh
[5 Feb 2021 0:00] Gustavo Cuatepotzo
Hi Joey,
Can you please test with the latest version?

Regards
[10 Aug 2022 21:16] Daniel Valdez
Issue could not be reproducible.