Could not load type 'SqlGuidCaster' from assembly System.Data.SqlClient on .NET 8 Preview
tippmar-nr opened this issue · 6 comments
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
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: |
|
Milestone: | - |
@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.
@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.
@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?
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
System.Data.SqlClient, is unlikely to receive further updates, much less those that are only for fixing Reflection issues.
Regards,
David