Author Topic: C# Reflection - How to load C# assembly at run time?  (Read 1274 times)


  • Administrator
  • Full Member
  • *****
  • Posts: 69
C# Reflection - How to load C# assembly at run time?
« on: November 01, 2011, 12:17:27 pm »
The following code would load the C# assembly at run time with System.Reflection.Assembly.LoadFile(filename) . Then it try to get the class name called "CMyTestClass" and sets the value as "Software&Finance" for the property named "MyPropertyName".

Assembly assembly = Assembly.LoadFile("c:\\testserver.dll");
Type classType = assembly.GetType("CMyTestClass");
object classObjInstance = Activator.CreateInstance(classType);

Note in this case, you do not need to have the assembly file loaded in the GAC. And also it does not bound to a specific version of the assembly.

PropertyInfo info = classType.GetProperty("MyPropertyName");
object[] args = { "Software&Finance" };
info.SetValue(classObjInstance, args[0], null);


  • Group8
  • *
  • Posts: 4
C# Reflection How to load C# assembly at run time
« Reply #1 on: January 18, 2017, 08:37:11 am »
Maybe if you share the source code and the exe we could help you to match the assembly code to the C code, or at least try to spot where the problem is.


Disclaimer: This web site is for educational and informational purposes only. Click here to read the Disclaimer.
Content copyright 2010-2014. Kathiresan. All rights reserved.
This page is using SMF version 2.0.1