コード例 #1
0
        public static BindOperation AssemblyLoadContextLoad()
        {
            var       assemblyName = new AssemblyName(SubdirectoryAssemblyName);
            var       assemblyPath = Helpers.GetAssemblyInSubdirectoryPath(assemblyName.Name);
            CustomALC alc          = new CustomALC(nameof(AssemblyLoadContextLoad));

            alc.EnableLoad(assemblyName.Name, assemblyPath);

            Assembly asm = alc.LoadFromAssemblyName(assemblyName);

            return(new BindOperation()
            {
                AssemblyName = assemblyName,
                AssemblyLoadContext = alc.ToString(),
                Success = true,
                ResultAssemblyName = asm.GetName(),
                ResultAssemblyPath = asm.Location,
                Cached = false,
                ResolutionAttempts = new List <ResolutionAttempt>()
                {
                    GetResolutionAttempt(assemblyName, ResolutionStage.FindInLoadContext, alc, ResolutionResult.AssemblyNotFound),
                    GetResolutionAttempt(assemblyName, ResolutionStage.AssemblyLoadContextLoad, alc, ResolutionResult.Success, asm)
                }
            });
        }