Example #1
0
        public Assembly ResolveAssembly(AssemblyName assemblyName, FunctionAssemblyLoadContext targetContext)
        {
            Assembly assembly = null;

            if (_externalReferences.TryGetValue(assemblyName.FullName, out string assemblyPath))
            {
                // For external references, we load the assemblies into the shared context:
                assembly = FunctionAssemblyLoadContext.Shared.LoadFromAssemblyPath(assemblyPath, true);
            }
            else if (TryResolvePrivateAssembly(assemblyName.FullName, out assemblyPath))
            {
                assembly = targetContext.LoadFromStream(new MemoryStream(File.ReadAllBytes(assemblyPath)));
            }
            else if (_packageAssemblyResolver.TryResolveAssembly(assemblyName.FullName, out assemblyPath))
            {
                assembly = targetContext.LoadFromAssemblyPath(assemblyPath);
            }
            else
            {
                _extensionSharedAssemblyProvider.TryResolveAssembly(assemblyName.FullName, FunctionAssemblyLoadContext.Shared, _logger, out assembly);
            }

            return(assembly);
        }