如何在运行时检索有关已加载程序集的信息? (C#、. NET)

编程入门 行业动态 更新时间:2024-10-25 20:24:54
本文介绍了如何在运行时检索有关已加载程序集的信息? (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)

本文发布于:2023-11-15 23:20:07,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1598852.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:加载   程序   如何在   信息   NET

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!