获取所有引用的程序集的路径 [英] Get the paths of all referenced assemblies

查看:580
本文介绍了获取所有引用的程序集的路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何获得当前正在执行的程序集引用的所有程序集的路径? GetReferencedAssmblies()给我的的AssemblyName [] 秒。我如何得到的地方,他们是从,装在那里?

How do I get the paths of all the assemblies referenced by the currently executing assembly? GetReferencedAssmblies() gives me the AssemblyName[]s. How do I get to where they are loaded from, from there?

推荐答案

您可以不知道,直到大会被加载。大会决议的算法是复杂的,你不能可靠地猜出前面什么都行。调用的Assembly.Load(的AssemblyName)重写将让你的程序集的引用,它的位置属性会告诉你你所需要的。

You cannot know until the assembly is loaded. The assembly resolution algorithm is complicated and you can't reliably guess up front what it will do. Calling the Assembly.Load(AssemblyName) override will get you a reference to the assembly, its Location property tells you what you need.

不过,你的真的的不希望加载组件前面,的的JIT编译器做的。它是低效率的和的问题的可能性不是零。之前的计划是准备作出回应例如,你可以触发一个事件AppDomain.AssemblyResolve。避免问这个问题。

However, you really don't want to load assemblies up front, before the JIT compiler does it. It is inefficient and the likelihood of problems is not zero. You could for example fire an AppDomain.AssemblyResolve event before the program is ready to respond to it. Avoid asking this question.

这篇关于获取所有引用的程序集的路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆