.net core 1.1: Type.GetType from external assembly returns null

I port the console application to the .NET kernel, which loads types from external libraries. Fully using the .NET Framework Type.GetType("typename, assemblyname")when the assembly is located in the same folder that is completed.

In .NET Core, it returns null wherever I place the library.

As a workaround, I installed the package System.Runtime.Loaderand connected to the event Resolvingto force download from the full path:

AssemblyLoadContext.Default.Resolving += Default_Resolving;
type = Type.GetType(value);

where is the delegate:

private static Assembly Default_Resolving(AssemblyLoadContext context, AssemblyName assembly)
{
    return context.LoadFromAssemblyPath(Path.Combine(Directory.GetCurrentDirectory(), @"bin\Debug\netcoreapp1.1",  $"{assembly.Name}.dll"));
}

Question: where does the .NET kernel work when loading an external assembly?

+4
source share
1 answer

, . . - nuget ( , .runtimeconfig.json .deps.json), DLL, .

; , , DLL.

: System.IO.Path.GetDirectoryName(typeof(myclassname).GetTypeInfo().Assembly.Location)

+2

Source: https://habr.com/ru/post/1676934/


All Articles