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

Could not load type 'SqlGuidCaster' from assembly System.Data.SqlClient on .NET 8 Preview #86969

Closed
tippmar-nr opened this issue May 31, 2023 · 6 comments

Comments

@tippmar-nr
Copy link

Description

Running on .NET 8 Preview 4, reflection into System.Data.SqlClient throws an exception:

Could not load type 'SqlGuidCaster' from assembly 'System.Data.SqlClient, Version=4.6.1.5, Culture=neutral, 
PublicKeyToken=b03f5f7f11d50a3a' because it contains an object field at offset 0 that is incorrectly aligned 
or overlapped by a non-object field.

This appears to be identical to the issue reported for Microsoft.Data.SqlClient a few months ago.

Reproduction Steps

Console app, targeting .NET 8 Preview 4.
Add the latest System.Data.SqlClient package

using System.Data.SqlClient;
using System.Linq;

namespace SDSqlClientRepro
{
    public class Program
    {
        public static void Main(string[] args)
        {
            var sqlConnection = new SqlConnection();

            var assemblies = AppDomain.CurrentDomain.GetAssemblies().ToList();

            foreach (var assembly in assemblies)
            {
                foreach (var type in assembly.GetTypes()) // boom
                {
                }
            }

            Console.WriteLine("Done!");
        }
   }
}

Expected behavior

Application should not throw an exception

Actual behavior

Exception as noted above

Regression?

Works fine under .NET 7.0

Known Workarounds

No response

Configuration

No response

Other information

No response

@ghost ghost added the untriaged New issue has not been triaged by the area owner label May 31, 2023
@ghost
Copy link

ghost commented May 31, 2023

Tagging subscribers to this area: @DavoudEshtehari, @David-Engel, @JRahnama
See info in area-owners.md if you want to be subscribed.

Issue Details

Description

Running on .NET 8 Preview 4, reflection into System.Data.SqlClient throws an exception:

Could not load type 'SqlGuidCaster' from assembly 'System.Data.SqlClient, Version=4.6.1.5, Culture=neutral, 
PublicKeyToken=b03f5f7f11d50a3a' because it contains an object field at offset 0 that is incorrectly aligned 
or overlapped by a non-object field.

This appears to be identical to the issue reported for Microsoft.Data.SqlClient a few months ago.

Reproduction Steps

Console app, targeting .NET 8 Preview 4.
Add the latest System.Data.SqlClient package

using System.Data.SqlClient;
using System.Linq;

namespace SDSqlClientRepro
{
    public class Program
    {
        public static void Main(string[] args)
        {
            var sqlConnection = new SqlConnection();

            var assemblies = AppDomain.CurrentDomain.GetAssemblies().ToList();

            foreach (var assembly in assemblies)
            {
                foreach (var type in assembly.GetTypes()) // boom
                {
                }
            }

            Console.WriteLine("Done!");
        }
   }
}

Expected behavior

Application should not throw an exception

Actual behavior

Exception as noted above

Regression?

Works fine under .NET 7.0

Known Workarounds

No response

Configuration

No response

Other information

No response

Author: tippmar-nr
Assignees: -
Labels:

area-System.Data.SqlClient

Milestone: -

@JRahnama
Copy link

@tippmar-nr this is a duplicate of #1930 in SqlClient. I will close this issue and you can follow the progress on the mentioned issue and related PR.

@ghost ghost removed the untriaged New issue has not been triaged by the area owner label May 31, 2023
@tippmar-nr
Copy link
Author

@JRahnama So should we expect this issue to be resolved for System.Data.SqlClient when it is resolved for Microsoft.Data.SqlClient? It looks like the fix will require a .NET 8 specific build of the package.

@JRahnama
Copy link

JRahnama commented Jun 1, 2023

@tippmar-nr System.Data.SqlClient is in servicing mode and is not receiving any update, but critical ones or security patches.

@danmoseley is this something that System.Data.SqlClient consider to backport?

@danmoseley
Copy link
Member

This is owned by the SQL team -- @David-Engel (per https://github.com/dotnet/runtime/blob/main/docs/area-owners.md) should answer.

Note, it may be easier to ask them over in https://github.com/dotnet/sqlclient

@David-Engel
Copy link
Contributor

System.Data.SqlClient, is unlikely to receive further updates, much less those that are only for fixing Reflection issues.

Regards,
David

@ghost ghost locked as resolved and limited conversation to collaborators Jul 2, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants