Could not load type 'SqlGuidCaster' from assembly Microsoft.Data.SqlClient
See original GitHub issueIs there an existing issue for this?
- I have searched the existing issues
Describe the bug
Error:
System.Reflection.ReflectionTypeLoadException: „Unable to load one or more of the requested types.
Could not load type 'SqlGuidCaster' from assembly 'Microsoft.Data.SqlClient, Version=5.0.0.0, Culture=neutral, PublicKeyToken=23ec7fc2d6eaa4a5' because it contains an object field at offset 0 that is incorrectly aligned or overlapped by a non-object field.”
Code:
public static IEnumerable<Assembly> GetAssembliesWithTypesImplementing<T>()
{
return AppDomain.CurrentDomain.GetAssemblies()
.SelectMany(assembly => assembly.GetTypes())
.Where(type => !type.IsAbstract && typeof(T).IsAssignableFrom(type))
.Select(type => type.Assembly)
.Distinct();
}
line:
assembly.GetTypes()
The error appeared after upgrading from .net 7 to .net 8 preview 1. I searched and I don’t have such Microsoft.Data.SqlClient package installed
Expected Behavior
No response
Steps To Reproduce
No response
Exceptions (if any)
No response
.NET Version
No response
Anything else?
No response
Issue Analytics
- State:
- Created 7 months ago
- Comments:18 (15 by maintainers)
Top Results From Across the Web
Could not load file or assembly 'Microsoft.Data.SqlClient
To resolve the version issue, in Visual Studio, right click on the solution and go to Manage NuGet Packages for Solution option and...
Read more >Could not load file or assembly System.Data.SqlClient
1. Make sure that the 'System.Data.SqlClient' assembly is present in your project's output directory or in a location where it can be discovered ......
Read more >How to fix Could not load type 'DTSTransform.SCD.6' from ...
I'm trying to run an Integration Services Assessment using the Data Migration Assessment tool, ... The exception was: Could not load type 'DTSTransform....
Read more >Could not load file or assembly Microsoft.Data.Services. ...
First check what version of this dll you have in your output directory. I'll bet that is 5.6.3.0, so: ... Please sign in...
Read more >Microsoft.SqlServer.BatchParserClient, Version=14.0.0.0
Hi, I am getting this error " System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.SqlServer.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Ok. that’s interesting. The problem isn’t in SqlClient it’s to do without how object layouts are computed in the Jit. It looks like a class that’s laid out safely in 7 is now not safe in 8. Since 8 is still in very early preview this isn’t a pressing problem but i’ll see if i can find the people who might know what to do.
This same issue is present in
System.Data.SqlClientas I reported here.Should we expect the fix for this issue to be backported from
Microsoft.Data.SqlClienttoSystem.Data.SqlClient?