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.
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.
Member
1 Points
1 Post
FileLoadException System.Data.Common
Sep 11, 2019 12:45 PM|Hadad82|LINK
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!
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.
All-Star
53554 Points
13305 Posts
Re: FileLoadException System.Data.Common
Sep 11, 2019 05:07 PM|bruce (sqlwork.com)|LINK
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.
Participant
1868 Points
1000 Posts
MVP
Re: FileLoadException System.Data.Common
Sep 11, 2019 05:16 PM|maherjendoubi|LINK
System.Data.Common is not compatible with the version 2.2 of .NET Core : https://www.nuget.org/packages/System.Data.Common/
Best regards,
Maher
Blog : https://maherjendoubi.io