locked
FileLoadException System.Data.Common RRS feed

  • Question

  • User-504537913 posted

    I'm developing .net core 2.2 web API, I'm using a separate custom assemblyLoadContext to load my controllers at run time. Each controller(or service)loaded in separate Context but I get below error in resolving SDK assembly!

    System.IO.FileLoadException: 'Could not load file or assembly 'System.Data.Common, Version=4.2.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. An operation is not legal in the current state. (Exception from HRESULT: 0x80131509)'  

    when I use the Default context to load all assemblies everything works well.

    in the design document of AssemblyLoadContext microsoft mentioned that if resolving assembly failed in the costume context core will fallback to default context which is not happened in my case.

    Wednesday, September 11, 2019 12:45 PM

Answers

  • User1289604957 posted

    System.Data.Common is not compatible with the version 2.2 of .NET <g class="gr_ gr_86 gr-alert gr_gramm gr_inline_cards gr_run_anim Style multiReplace" id="86" data-gr-id="86">Core :</g> https://www.nuget.org/packages/System.Data.Common/

    Best regards,

    Maher

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, September 11, 2019 5:16 PM

All replies

  • User-474980206 posted

    you should load all dependent assemblies in the default context, as the caller probably does not know about your custom context. 

    unlike old .net which a process could have separate  appdomains that you loaded assemblies in, .net core does not. assemblies are just loaded into the process. the AssemblyContext is a simple technique to dynamically load an assembly opaquely.

    Wednesday, September 11, 2019 5:07 PM
  • User1289604957 posted

    System.Data.Common is not compatible with the version 2.2 of .NET <g class="gr_ gr_86 gr-alert gr_gramm gr_inline_cards gr_run_anim Style multiReplace" id="86" data-gr-id="86">Core :</g> https://www.nuget.org/packages/System.Data.Common/

    Best regards,

    Maher

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, September 11, 2019 5:16 PM