c# - 我可以获取网站引用的所有程序集吗

标签 c# asp.net

基本上,我想在我的 MVC 站点内的页面上打印一个列表,其中显示应用程序使用的所有程序集以及版本信息。

我不想只将那些包含在 bin 目录中,我想使用更准确的方法。

所以例子是

我想知道正在使用 bin 目录中的哪些 dll。对于其中的每一个,我都需要查看它们的依赖程序集(及其版本信息)。

我想知道从 GAC 等引用了哪些 dll。

我希望获得尽可能多的相关信息,因此诸如程序集期望的版本以及应用程序正在获取的内容等信息将很有用。

是否有任何标准方法?

谢谢, 马丁

最佳答案

考虑使用 BuildManager.GetReferencedAssemblies其中:

Returns a list of assembly references that all page compilations must reference.

示例用法:

var assemblies = BuildManager.GetReferencedAssemblies().Cast<Assembly>();

另请注意此方法与 AppDomain.GetAssemblies() 之间的重要区别。 BuildManager.GetReferencedAssemblies 返回:

assemblies specified in the assemblies element of the Web.config file, assemblies built from custom code in the App_Code directory, and assemblies in other top-level folders.

AppDomain.GetAssemblies() 仅返回当前加载的程序集。

关于c# - 我可以获取网站引用的所有程序集吗,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23290601/

相关文章:

c# - NUnit 的一次性初始化

c# - 设置代理 Windows IOT Core

c# - .NET System.Process : when you redirect StandardError, 控制台窗口没有收到任何输出

c# - 替换以 “A” 开头,包含一个或多个 "B"并以 C 结尾的单词

asp.net - 当启用 EnabledEventValidation 时,Firefox 中出现无效 ViewState 错误

asp.net - 使用asp.net从windows服务器连接到Red hat linux上的oracle 11g

c# - SQL插入-删除表

javascript - 是否可以在 Javascript 函数中调用 ASP.NET 函数?

c# - 嵌入图像在浏览器中显示时未在 Outlook 中显示?

asp.net - 如何防止 Ajax.BeginForm 加载新页面?