Advertisement
EddyCZ

Untitled

Apr 16th, 2023
904
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.66 KB | None | 0 0
  1. using System;
  2. using System.Reflection;
  3.  
  4. namespace MyNamespace
  5. {
  6.     class MyClass
  7.     {
  8.         static void Main(string[] args)
  9.         {
  10.             // Load the external DLL
  11.             Assembly assembly = Assembly.LoadFile("path/to/mydll.dll");
  12.  
  13.             // Get the type of the class you want to invoke
  14.             Type type = assembly.GetType("MyNamespace.MyClass");
  15.  
  16.             // Create an instance of the class
  17.             object instance = Activator.CreateInstance(type);
  18.  
  19.             // Invoke a method on the class
  20.             MethodInfo method = type.GetMethod("MyMethod");
  21.             method.Invoke(instance, null);
  22.         }
  23.     }
  24. }
  25.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement