BuildManager.GetReferencedAssemblies equivalent for non-web applications

前端 未结 3 1158
鱼传尺愫
鱼传尺愫 2021-02-07 12:26

Compared to AppDomain.GetAssemblies(), BuildManager.GetReferencedAssemblies() (System.Web.Compilation.BuildManager) seems a more reliable way to get th

3条回答
  •  别那么骄傲
    2021-02-07 12:33

    The only way I currently see is pre-fetching all referenced assemblies manually, just as the BuildManager does under the covers:

    var assemblies =
        from file in Directory.GetFiles(AppDomain.CurrentDomain.BaseDirectory)
        where Path.GetExtension(file) == ".dll"
        select Assembly.LoadFrom(file);
    

提交回复
热议问题