Ash Machine
Ash Machine

Reputation: 9921

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

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!

Upvotes: 1

Views: 5146

Answers (2)

Jon Skeet
Jon Skeet

Reputation: 1503459

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.

Upvotes: 4

JP Alioto
JP Alioto

Reputation: 45127

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

var la = AppDomain.CurrentDomain.GetAssemblies();

Upvotes: 8

Related Questions