Exception Loading System.Memory.dll from System.Data.SqlClient

Allanjb 246 Reputation points

While executing an SqlConnection.Open() command in Debug, I get the following exception:
"Could not load file or assembly 'System.Memory, Version=, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'. The system cannot find the file specified.":"System.Memory, Version=, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51"

In the Output Window I get:
"Exception thrown: 'System.IO.FileNotFoundException' in System.Data.SqlClient.dll"

When running the App in release mode, I don't get any exceptions and the App runs as expected.
I have tried all the usual things like reinstalling System.Data.SqlClient and deleting all the bin and obj files, to no avail.
I am using Visual Studio 2019 with all the latest builds so puzzled as to what is happening.

If I copy the version of system.memory.dll in the release folder to the debug folder and overwrite the copy in debug, everything works fine.
The copy in the release folder is dated: 20-Nov-20, v4.6.29301.02
The copy in the debug folder is dated 19-Feb-20, v4.6.28619.01

Universal Windows Platform (UWP)
SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
12,862 questions
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,559 questions
{count} votes