AppDomainToolkit.AssemblyTarget.FromPath C# (CSharp) Метод

FromPath() публичный статический Метод

Creates a new assembly target for the given location. The only required parameter here is the codebase.
public static FromPath ( Uri codebase, string location = null, string fullname = null ) : IAssemblyTarget
codebase System.Uri /// The URI to the code base. ///
location string /// The location. Must be a valid path and an existing file if supplied--defaults to null. ///
fullname string /// The full name of the assembly. Defaults to null. ///
Результат IAssemblyTarget
        public static IAssemblyTarget FromPath(Uri codebase, string location = null, string fullname = null)
        {
            if (codebase == null)
            {
                throw new ArgumentNullException("codebase", "Codebase URI cannot be null!");
            }

            if (!File.Exists(codebase.LocalPath))
            {
                throw new FileNotFoundException("The target location must be an existing file!");
            }

            if (!string.IsNullOrEmpty(location) && !File.Exists(location))
            {
                throw new FileNotFoundException("The target location must be an existing file!");
            }

            return new AssemblyTarget()
            {
                CodeBase = codebase,
                Location = location,
                FullName = fullname,
                IsDynamic = false,
            };
        }

Usage Example

Пример #1
0
        /// <inheritdoc/>
        public IAssemblyTarget LoadAssembly(LoadMethod loadMethod, string assemblyPath, string pdbPath = null)
        {
            IAssemblyTarget target   = null;
            var             assembly = this.loader.LoadAssembly(loadMethod, assemblyPath, pdbPath);

            if (loadMethod == LoadMethod.LoadBits)
            {
                // Assemlies loaded by bits will have the codebase set to the assembly that loaded it. Set it to the correct path here.
                var codebaseUri = new Uri(assemblyPath);
                target = AssemblyTarget.FromPath(codebaseUri, assembly.Location, assembly.FullName);
            }
            else
            {
                target = AssemblyTarget.FromAssembly(assembly);
            }

            return(target);
        }