■ 참조 어셈블리를 로드하는 방법을 보여준다.
▶ Program.cs
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
using System.Reflection; namespace TestProject; /// <summary> /// 프로그램 /// </summary> class Program { //////////////////////////////////////////////////////////////////////////////////////////////////// Method ////////////////////////////////////////////////////////////////////////////////////////// Static //////////////////////////////////////////////////////////////////////////////// Private #region 참조 어셈블리 로드하기 - LoadReferencedAssembly(assembly, assemblyLevel) /// <summary> /// 참조 어셈블리 로드하기 /// </summary> /// <param name="assembly">어셈블리</param> /// <param name="assemblyLevel">어셈블리 레벨</param> private static void LoadReferencedAssembly(Assembly assembly, int assemblyLevel = 0) { Console.WriteLine($"{" ".PadRight(assemblyLevel * 4)}{assembly.GetName().Name}"); foreach(AssemblyName name in assembly.GetReferencedAssemblies()) { if(!AppDomain.CurrentDomain.GetAssemblies().Any(a => a.FullName == name.FullName)) { LoadReferencedAssembly(Assembly.Load(name), assemblyLevel + 1); } } } #endregion #region 프로그램 시작하기 - Main() /// <summary> /// 프로그램 시작하기 /// </summary> private static void Main() { foreach(Assembly assembly in AppDomain.CurrentDomain.GetAssemblies()) { LoadReferencedAssembly(assembly); } } #endregion } |