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



Question:

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!


Solution: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.


Solution:2

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

var la = AppDomain.CurrentDomain.GetAssemblies();  

Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »