如何在运行时检索有关已加载程序集的信息? (C#、. NET) [英] How to retrieve info on a loaded assembly at runtime? (c# , .NET)

查看:312
本文介绍了如何在运行时检索有关已加载程序集的信息? (C#、. NET)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在.NET c#3.5中,我有一个控制台应用程序(A),它引用了几个程序集(X,Y,Z).

In .NET c# 3.5 I have a console application (A) that references several assemblies(X, Y, Z).

如何在运行时获取已加载程序集的版本信息?

How can I get the version information of the loaded assemblies at run time?

我可以使用反射来获取有关当前正在执行的程序集的信息

I can use reflection to get the info on the currently executing assembly like this

System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString()

,但不加载的程序集.感谢您的帮助!

but not the loaded assemblies. Thanks for your help!

推荐答案

JP的答案将为您提供AppDomain中的所有程序集.如果只希望当前程序集直接引用的程序集,则可以使用:

JP's answer will give you all of the assemblies in the AppDomain. If you only want the assemblies that your current assembly references directly, you can use:

var names = Assembly.GetExecutingAssembly().GetReferencedAssemblies();

这将为您提供名称,包括版本信息.

That will give you the names, including version information.

这篇关于如何在运行时检索有关已加载程序集的信息? (C#、. NET)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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