예제 #1
0
 /// <summary>
 /// Loads the assembly.
 /// </summary>
 /// <param name="file">The file.</param>
 /// <returns>Assembly.</returns>
 protected Assembly LoadAssembly(string file)
 {
     try
     {
         return(Assembly.Load(File.ReadAllBytes((file))));
     }
     catch (Exception ex)
     {
         FailedAssemblies.Add(file);
         Logger.ErrorException("Error loading assembly {0}", ex, file);
         return(null);
     }
 }
예제 #2
0
        /// <summary>
        /// Loads the assembly.
        /// </summary>
        /// <param name="file">The file.</param>
        /// <returns>Assembly.</returns>
        protected Assembly LoadAssembly(string file)
        {
            try
            {
#if NET46
                return(Assembly.Load(File.ReadAllBytes(file)));
#elif NETSTANDARD1_6
                return(AssemblyLoadContext.Default.LoadFromStream(new MemoryStream(File.ReadAllBytes(file))));
#endif
                return(null);
            }
            catch (Exception ex)
            {
                FailedAssemblies.Add(file);
                Logger.ErrorException("Error loading assembly {0}", ex, file);
                return(null);
            }
        }