在C#中可以通过Assembly来动态加载DLL,然后由它创建类型,接着通过类型的InvokeMember方法来调用DLL中类的方法以及属性。
为了方便说明一下的方法,先说明一下DLL的代码,大致如下:
using System;
namespace clsTestDll
{
/// <summary>
/// Summary description for TestDll.
/// </summary>
public class TestDll
{
private string strName;
public TestDll()
{
//
// TODO: Add constructor logic here

本文介绍了如何在C#中使用Assembly动态加载DLL,并通过InvokeMember方法调用类的方法和属性。示例代码展示了加载DLL、创建类型、调用静态与非静态方法以及设置和获取属性值的过程。
最低0.47元/天 解锁文章
3万+





