Skip to content

missing NeutralResourcesLanguage attribute? #426

Closed

Description

@BradBarnich

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.
image

Activity

  1. cheenamalhotra commented on Feb 13, 2020

    @cheenamalhotra
    Member

    Hi @BradBarnich

    Could you provide us a repro to try the same and reproduce error?
    A sample would definitely be helpful.

  2. cheenamalhotra commented on Feb 13, 2020

    @cheenamalhotra
    Member

    The repro is missing "packages" folder required for restore.
    Since you have direct assembly references, could you upload them as well?

  3. BradBarnich commented on Feb 14, 2020

    @BradBarnich
    ContributorAuthor

    Ok, I've committed the restored nuget packages.

  4. cheenamalhotra commented on Feb 14, 2020

    @cheenamalhotra
    Member

    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!

  5. BradBarnich commented on Feb 17, 2020

    @BradBarnich
    ContributorAuthor

    @cheenamalhotra fantastic! works great with that version.

    Any chance it could be ported to the 1.x releases?

  6. cheenamalhotra commented on Feb 19, 2020

    @cheenamalhotra
    Member

    @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.

  7. added this to the 2.0.0 milestone on Feb 19, 2020
  8. BradBarnich commented on Feb 26, 2020

    @BradBarnich
    ContributorAuthor
  9. franzzua commented on Jun 11, 2020

    @franzzua

    Hello!
    Could you say, has it merged in 1.1.3?
    I have same error with 'Microsoft.Data.SqlClient.resources' now

  10. cheenamalhotra commented on Jun 11, 2020

    @cheenamalhotra
    Member

    @franzzua

    This hasn't been backported to v1.1 series.
    Could you try out with v2.0.0-preview2+?

  11. BradBarnich commented on Jun 12, 2020

    @BradBarnich
    ContributorAuthor

    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)

  12. ErikEJ commented on Jun 12, 2020

    @ErikEJ
    Contributor

    @BradBarnich this month according to plan.

  13. cheenamalhotra commented on Jun 12, 2020

    @cheenamalhotra
    Member

    Hi @BradBarnich

    We're targeting release next week.

  14. sharpninja commented on Nov 25, 2020

    @sharpninja

    We shall wait for more interest in this request from different audiences

    I have this issue in Azure DevOps running Cake Build with Microsoft.Data.SqllClient

  15. nvmkpk commented on Feb 29, 2024

    @nvmkpk

    I am running into the same error now:

          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=5.0.0.0, Culture=en-US, PublicKeyToken=23ec7fc2d6eaa4a5'. The system cannot find the file specified.
          File name: 'Microsoft.Data.SqlClient.resources, Version=5.0.0.0, Culture=en-US, PublicKeyToken=23ec7fc2d6eaa4a5'
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions