Load Assembly : Module « Reflection « C# / C Sharp






Load Assembly

  

using System;
using System.Reflection;
using System.Diagnostics;
   
    public class AssemblyUtils
    {
        public static string GetAssemblyName(string[] args)
        {
            string assemblyName;
   
            if (0 == args.Length)
            {
                Process p = Process.GetCurrentProcess();
                assemblyName = p.ProcessName + ".exe";
            }
            else
                assemblyName = args[0];
   
            return assemblyName;
        }
    }

   
class GetModulesApp
{
    public static void Main(string[] args)
    {
        string assemblyName = AssemblyUtils.GetAssemblyName(args);
   
        Console.WriteLine("Loading info for " + assemblyName);
        Assembly a = Assembly.LoadFrom(assemblyName);
   
        Module[] modules = a.GetModules();
        foreach(Module m in modules)
        {
            Console.WriteLine("Module: " + m.Name);
        }
    }
}

   
  








Related examples in the same category

1.Module Class Performs reflection on a module.
2.Module.Assembly
3.Module.FilterTypeName
4.Module.Filter Type Name
5.Module.Fully Qualified Name
6.Module.Is Defined
7.Module.Is Resource
8.Module.ToString