Repository navigation
Description
Describe the bug
When loading an efcore 3.1.1 project using reflection, an exception is thrown by Microsoft.Data.SqlClient looking for the en-US satellite assembly (which doesn't exist).
I am unfamiliar with ResourceManager and satellite assemblies but it looks like it might be that the Microsoft.Data.SqlClient.dll assembly is missing [assembly: NeutralResourcesLanguage("en-US")] ?
Stack trace:
System.TypeInitializationException: The type initializer for 'Microsoft.Data.SqlClient.SqlConnection' threw an exception.
---> System.TypeInitializationException: The type initializer for 'Microsoft.Data.SqlClient.SqlConnectionFactory' threw an exception.
---> System.TypeInitializationException: The type initializer for 'Microsoft.Data.SqlClient.SqlPerformanceCounters' threw an exception.
---> System.TypeInitializationException: The type initializer for 'Microsoft.Data.Common.ADP' threw an exception.
---> System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.Data.SqlClient.resources, Version=1.10.19324.4, Culture=en-US, PublicKeyToken=23ec7fc2d6eaa4a5' or one of its dependencies. The system cannot find the file specified.
---> System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.Data.SqlClient.resources' or one of its dependencies. The system cannot find the file specified.
at System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
at System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
at System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean forIntrospection)
at System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection)
at System.Reflection.Assembly.Load(String assemblyString)
at CareEvolution.DatabaseMigrations.DatabaseMigrator.AssemblyResolve(Object sender, ResolveEventArgs args)
at System.AppDomain.OnAssemblyResolveEvent(RuntimeAssembly assembly, String assemblyFullName)
--- End of inner exception stack trace ---
at System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
at System.Reflection.RuntimeAssembly.InternalGetSatelliteAssembly(String name, CultureInfo culture, Version version, Boolean throwOnFileNotFound, StackCrawlMark& stackMark)
at System.Resources.ManifestBasedResourceGroveler.GetSatelliteAssembly(CultureInfo lookForCulture, StackCrawlMark& stackMark)
at System.Resources.ManifestBasedResourceGroveler.GrovelForResourceSet(CultureInfo culture, Dictionary`2 localResourceSets, Boolean tryParents, Boolean createIfNotExists, StackCrawlMark& stackMark)
at System.Resources.ResourceManager.InternalGetResourceSet(CultureInfo requestedCulture, Boolean createIfNotExists, Boolean tryParents, StackCrawlMark& stackMark)
at System.Resources.ResourceManager.InternalGetResourceSet(CultureInfo culture, Boolean createIfNotExists, Boolean tryParents)
at System.Resources.ResourceManager.GetString(String name, CultureInfo culture)
at Microsoft.Data.Common.ADP..cctor()
To reproduce
I can try to extract a sample if that would be helpful.
Expected behavior
A satellite assembly should't be loaded for en-US, since those resources are in the main assembly.
Further technical details
Microsoft.Data.SqlClient version: 1.10.19324.4
.NET target: Framework 4.8
SQL Server version: N/A
Operating system: Windows 10
Additional context
Here is a capture from procmon when this exception occurred, can see the files that .NET is looking for.

Activity
cheenamalhotra commentedon Feb 13, 2020
Hi @BradBarnich
Could you provide us a repro to try the same and reproduce error?
A sample would definitely be helpful.
BradBarnich commentedon Feb 13, 2020
Sure. https://github.com/BradBarnich/sqlclient426repro
cheenamalhotra commentedon Feb 13, 2020
The repro is missing "packages" folder required for restore.
Since you have direct assembly references, could you upload them as well?
BradBarnich commentedon Feb 14, 2020
Ok, I've committed the restored nuget packages.
cheenamalhotra commentedon Feb 14, 2020
Hi @BradBarnich
I was able to reproduce the error and have a proposed version [
2.0.0-dev] for you to try.Microsoft.Data.SqlClient.2.0.0-dev.zip
PR #433 contains the changes done, let us know if that resolves your issue!
BradBarnich commentedon Feb 17, 2020
@cheenamalhotra fantastic! works great with that version.
Any chance it could be ported to the 1.x releases?
cheenamalhotra commentedon Feb 19, 2020
@BradBarnich
I do see the attribute is a miss when porting System.Data.SqlClient to Microsoft.Data.SqlClient, but we haven't heard about the same issue before, so I'm not sure what range of audience are affected by this.
We shall wait for more interest in this request from different audiences, and if it does seem to lay to a bigger impact, we can consider back-porting to 1.x release. Otherwise it'll be part of 2.0.0-preview2 as planned for next month, and hence-forth.
You may also choose to build a private library over 1.1.1 release version by forking and appending this fix if this blocks you.
BradBarnich commentedon Feb 26, 2020
Thanks @cheenamalhotra!
franzzua commentedon Jun 11, 2020
Hello!
Could you say, has it merged in 1.1.3?
I have same error with 'Microsoft.Data.SqlClient.resources' now
cheenamalhotra commentedon Jun 11, 2020
@franzzua
This hasn't been backported to v1.1 series.
Could you try out with v2.0.0-preview2+?
BradBarnich commentedon Jun 12, 2020
Do you know when v2.0 will be released? our .net core migration is on hold due to this issue (via ef core's dependency on this sqlclient vs the older one)
ErikEJ commentedon Jun 12, 2020
@BradBarnich this month according to plan.
cheenamalhotra commentedon Jun 12, 2020
Hi @BradBarnich
We're targeting release next week.
sharpninja commentedon Nov 25, 2020
I have this issue in Azure DevOps running Cake Build with Microsoft.Data.SqllClient
nvmkpk commentedon Feb 29, 2024
I am running into the same error now: