Exemplo n.º 1
0
 public LibraryAssemblyLoadContext(ProjectAssemblyLoader projectAssemblyLoader,
                                   NuGetAssemblyLoader nugetAssemblyLoader,
                                   IAssemblyLoadContext defaultContext)
 {
     _projectAssemblyLoader = projectAssemblyLoader;
     _nugetAssemblyLoader   = nugetAssemblyLoader;
     _defaultContext        = defaultContext;
 }
Exemplo n.º 2
0
 public LibraryAssemblyLoadContext(ProjectAssemblyLoader projectAssemblyLoader,
                                   NuGetAssemblyLoader nugetAssemblyLoader,
                                   IAssemblyLoadContext defaultContext)
 {
     _projectAssemblyLoader = projectAssemblyLoader;
     _nugetAssemblyLoader = nugetAssemblyLoader;
     _defaultContext = defaultContext;
 }
        private Assembly CurrentDomain_AssemblyResolve(object sender, ResolveEventArgs args) {
            var assemblyName = new AssemblyName(args.Name);

            Logger.Debug("Resolving " + assemblyName);

            var packageLoader = _packageAssemblyLookup.GetLoaderForPackage(assemblyName.Name);

            if (packageLoader != null) {
                var lookup = packageLoader
                    .PackageAssemblyLookup
                    .Single(x => x.Key.Name == assemblyName.Name);

                var loader = new NuGetAssemblyLoader(
                    _assemblyLoadContextAccessor,
                    packageLoader);

                Logger.Debug("Resolved " + assemblyName);
                var assembly = loader.Load(lookup.Key);
                return assembly;
            }

            Logger.Debug("Cannot resolve " + assemblyName);
            return null;
        }