Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When using Microsoft.Data.SqlClient an InvalidCastException will be thrown #51

Closed
yorek opened this issue Oct 8, 2020 · 3 comments
Closed

Comments

@yorek
Copy link

yorek commented Oct 8, 2020

When using Microsoft.Data.SqlClient 2.0.1 the following exception will be generated

[System.InvalidCastException] Unable to cast object of type 'Microsoft.SqlServer.Types.SqlHierarchyId' to type 'Microsoft.Data.SqlClient.Server.IBinarySerialize'.
once proper assembly redirection is in place

 if (assemblyName.FullName == "Microsoft.SqlServer.Types, Version=10.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91")
            {
                var a = typeof(SqlGeography).Assembly;
                _logger.Info("Rebinding to " + a.FullName);
                return a;
            }

yorek added a commit to yorek/Microsoft.SqlServer.Types that referenced this issue Oct 8, 2020
@dotMorten
Copy link
Owner

dotMorten commented Oct 8, 2020

Microsoft.Data.SqlClient isn't supported. Likely duplicate of: #29
Fixing that would be a major breaking change, so would have to be a separate build/package

@yorek
Copy link
Author

yorek commented Oct 8, 2020

I understand...I've submitted a PR to make it work with Microsoft.Data.SqlClient. It probably make sense to keep support to both, even if the newer Microsoft.Data.SqlClient is the preferred library (as per https://devblogs.microsoft.com/dotnet/introducing-the-new-microsoftdatasqlclient/)

yorek added a commit to yorek/Microsoft.SqlServer.Types that referenced this issue Oct 8, 2020
ErikEJ pushed a commit to ErikEJ/Microsoft.SqlServer.Types that referenced this issue Dec 12, 2020
@dotMorten
Copy link
Owner

Fixed in #69

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants