views:

526

answers:

2

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!

+6  A: 

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

var la = AppDomain.CurrentDomain.GetAssemblies();
JP Alioto
What he said. AppDomain is fun at time.
Gromer
+1  A: 

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.

Jon Skeet