Today I am going to show how to print out assemblies used by the running application. This information may be useful for logs and can be collected on application/service start.
Below is a snippet of the console application that prints out information to console.
using System;
using System.Diagnostics;
namespace ConsoleApplication
{
public class Program
{
public static void Main(string[] args)
{
Process oProcess = Process.GetCurrentProcess( );
Console.WriteLine( string.Format( "Process: {0} ({1})",
oProcess.ProcessName, oProcess.Id ) );
Console.WriteLine( );
Console.WriteLine( "MODULES:" );
Console.WriteLine( "________" );
foreach ( ProcessModule oModule in oProcess.Modules )
{
Console.WriteLine( string.Format( "{0} ({1})",
oModule.ModuleName, oModule.FileName ) );
}
}
}
}