// Collection of code snippets by Arne Vajhøj // (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) using System; using System.IO; using System.Reflection; namespace E { public class Program { public static void MyAssemblyLoadEventHandler(object sender, AssemblyLoadEventArgs args) { foreach(Type typ in args.LoadedAssembly.GetExportedTypes()) { if(Attribute.GetCustomAttribute(typ, typeof(InitableAttribute)) != null) { typ.InvokeMember("Init", BindingFlags.Public | BindingFlags.Static | BindingFlags.InvokeMethod, null, null, new object[0]); } } } public static void Main(string[] args) { AppDomain.CurrentDomain.AssemblyLoad += new AssemblyLoadEventHandler(MyAssemblyLoadEventHandler); foreach(FileInfo fi in (new DirectoryInfo(".")).GetFiles("P*.dll")) { Assembly.Load(Path.GetFileNameWithoutExtension(fi.Name)); } } } }