.Net Core 获取项目所有程序集,排除Microsoft、Nuget下载的

https://www.cnblogs.com/yanglang/p/6866165.html

 

public static List<Assembly> BaiqianAssemblies
        {
            get
            {
                var list = new List<Assembly>();
                var deps = DependencyContext.Default;
                var libs = deps.CompileLibraries.Where(lib => !lib.Serviceable && lib.Type != "package" && lib.Name.StartsWith("Baiqian"));
                foreach (var lib in libs)
                {
                    var assembly = AssemblyLoadContext.Default.LoadFromAssemblyName(new AssemblyName(lib.Name));
                    list.Add(assembly);
                }
                return list;
            }
        }

  

posted @ 2019-06-03 12:39  百小僧  阅读(1761)  评论(0编辑  收藏  举报