Skip to content

Instantly share code, notes, and snippets.

@markembling
Created November 9, 2016 17:44
Show Gist options
  • Save markembling/4d113af09029933f6206ba3f94a534ad to your computer and use it in GitHub Desktop.
Save markembling/4d113af09029933f6206ba3f94a534ad to your computer and use it in GitHub Desktop.
Tiny demo app which shows listing out all loaded assemblies and their information, and also listing out all references.
using System;
using System.Diagnostics;
using System.IO;
using System.Reflection;
namespace ConsoleApplication1 {
class Program {
static void Main(string[] args) {
Console.WriteLine("CLR");
Console.WriteLine(Environment.Version);
Console.WriteLine("==========");
Console.WriteLine("Loaded assemblies in this appdomain");
Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();
foreach (var assembly in assemblies) {
if (!assembly.GlobalAssemblyCache
&& !string.IsNullOrEmpty(assembly.Location)
/*&& assembly != Assembly.GetEntryAssembly()*/) {
FileVersionInfo versionInfo = FileVersionInfo.GetVersionInfo(assembly.Location);
Console.WriteLine("------------");
Console.WriteLine("1> " + versionInfo.FileDescription);
Console.WriteLine("2> " + versionInfo.FileVersion);
Console.WriteLine("3> " + versionInfo.CompanyName);
Console.WriteLine("4> " + Path.GetFileName(assembly.Location));
Console.WriteLine("5> " + versionInfo.FileDescription);
Console.WriteLine("6> " + versionInfo.LegalCopyright);
}
}
Console.WriteLine("==========");
Console.WriteLine("Referenced assemblies");
var referenced = Assembly.GetEntryAssembly().GetReferencedAssemblies();
foreach (var assembly in referenced) {
Console.WriteLine("------------");
Console.WriteLine("1> " + assembly.Name);
Console.WriteLine("2> " + assembly.FullName);
Console.WriteLine("3> " + assembly.Version);
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment