Using Microsoft.Data.SqlClient 5.0.1 causes System.TypeLoadException: Could not load type 'Microsoft.Data.SqlClient.Server.IBinarySerialize'

#78 · closed · 10 comments

View on GitHub ↗

alansingfield

Project works correctly on SqlClient 4.4.0. When we update to Microsoft.Data.SqlClient 5.0.1, get this error: > System.TypeLoadException: Could not load type 'Microsoft.Data.SqlClient.Server.IBinarySerialize' from assembly 'Microsoft.Data.SqlClient, > Version=5.0.0.0, Culture=neutral, PublicKeyToken=23ec7fc2d6eaa4a5'.**** > Problem is caused by a breaking change listed in: https://github.com/dotnet/SqlClient/blob/main/release-notes/5.0/5.0.0.md IBinarySerialize has been moved to package Microsoft.SqlServer.Server 1.0.0. I'm working on a PR now to fix this.

Comments

alansingfield

OK - looks like it's a problem on Microsoft.Data.SqlClient rather than this library.

alansingfield

I took a fork and made a 5.0 compatible version at https://github.com/alansingfield/Microsoft.SqlServer.Types https://www.nuget.org/packages/alansingfield.Microsoft.SqlServer.Types

ErikEJ

Have you tried the latest Microsoft.SqlServer.Types package??

alansingfield

Oops - didn't spot that one! I must have had the exclude prerelease flag turned on in NuGet. I've replaced the reference and it's all working. I'll deprecate my fork as it's no longer needed. Thanks for your help!

ErikEJ

>> I'll deprecate my fork as it's no longer needed. Or remove it?

MaceWindu

FYI, it is still useful as `Microsoft.SqlServer.Types` is Windows-only package

dotMorten

The preview supports more platforms than just Windows and more are coming

MaceWindu

It calls native `SqlServerSpatial160.dll` dll. You want to say it works on linux/macos? Cannot test it right now

dotMorten

Yup p/invoke is smart on .net and will call SqlServerSpatial160.so on Linux. Check the runtimes folder in the nuget package to get an idea of platforms currently supported. They also confirmed iOS and Android support is coming…

MaceWindu

`Microsoft.SqlServer.Types` ships only windows runtime (as of `160.900.6-rc0 `)