public TryResolveAssembly ( string name, string &path ) : bool | ||
name | string | |
path | string | |
Résultat | bool |
public Assembly ResolveAssembly(string assemblyName) { Assembly assembly = null; string assemblyPath = null; if (_externalReferences.TryGetValue(assemblyName, out assemblyPath)) { // When loading shared assemblies, load into the load-from context and load assembly dependencies assembly = Assembly.LoadFrom(assemblyPath); } else if (TryResolvePrivateAssembly(assemblyName, out assemblyPath)) { assembly = Assembly.Load(File.ReadAllBytes(assemblyPath)); assembly.MapCodeBase(assemblyPath); } else if (_packageAssemblyResolver.TryResolveAssembly(assemblyName, out assemblyPath)) { // Use LoadFile here to load into the correct context assembly = Assembly.LoadFile(assemblyPath); } else if (_extensionSharedAssemblyProvider.TryResolveAssembly(assemblyName, out assembly)) { return(assembly); } return(assembly); }
public Assembly ResolveAssembly(string assemblyName) { Assembly assembly = null; string assemblyPath = null; if (TryResolvePrivateAssembly(assemblyName, out assemblyPath) || _packageAssemblyResolver.TryResolveAssembly(assemblyName, out assemblyPath)) { // Use LoadFile here to load into the correct context assembly = Assembly.LoadFile(assemblyPath); } return(assembly); }
public Assembly ResolveAssembly(string assemblyName) { Assembly assembly = null; string assemblyPath = null; if (_externalReferences.TryGetValue(assemblyName, out assemblyPath)) { // When loading shared assemblies, load into the load-from context and load assembly dependencies assembly = Assembly.LoadFrom(assemblyPath); } else if (TryResolvePrivateAssembly(assemblyName, out assemblyPath) || _packageAssemblyResolver.TryResolveAssembly(assemblyName, out assemblyPath)) { // Use LoadFile here to load into the correct context assembly = Assembly.LoadFile(assemblyPath); } return(assembly); }
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); }
public void TryResolveAssembly_WithReferencedFrameworkAssemblyName_ResolvesAssemblyAndReturnsTrue() { var functionMetadata = new FunctionMetadata() { Name = "TestFunction", ScriptFile = _lockFilePath, /*We just need the path from this*/ ScriptType = ScriptType.CSharp }; var assemblyResolver = new PackageAssemblyResolver(functionMetadata); string assemblyPath; bool result = assemblyResolver.TryResolveAssembly("System.Net.Http", out assemblyPath); Assert.True(result); Assert.Equal("System.Net.Http", assemblyPath); }
public void TryResolveAssembly_WithReferencedAssemblyName_ResolvesAssemblyPathAndReturnsTrue() { var functionMetadata = new FunctionMetadata() { Name = "TestFunction", ScriptFile = _lockFilePath, /*We just need the path from this*/ ScriptType = ScriptType.CSharp }; var assemblyResolver = new PackageAssemblyResolver(functionMetadata); string assemblyPath; bool result = assemblyResolver.TryResolveAssembly(this.GetType().Assembly.FullName, out assemblyPath); Assert.True(result); Assert.Equal(_targetAssemblyFilePath, assemblyPath); }