How to retrieve info on a loaded assembly at runtime? (c# , .NET)

三世轮回 提交于 2019-12-11 06:21:17

问题


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!


回答1:


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.




回答2:


You can get the list of loaded assemblies from the AppDomain ...

var la = AppDomain.CurrentDomain.GetAssemblies();


来源:https://stackoverflow.com/questions/866487/how-to-retrieve-info-on-a-loaded-assembly-at-runtime-c-net

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!