C#动态调用dll
有个 DLL文件 路径是:D:\123123\123.dll ,要调用这个DLL文件里面的 1234方法,
1234 方法 :
参数1: string a
参数2: int b
返回值: bool c
求代码!这里感谢了!
[解决办法]
using System.Runtime.InteropServices;
public sealed class Dll123{
[DllImport("D:\123123\123.dll", EntryPoint = "1234")]
public static extern bool 1234(string a, int b);
}
[解决办法]
Type type= System.Reflection.Assembly.LoadFile(@"D:\123123\123.dll").GetType("Lib.MyClass");
object obj = type.GetMethod("1234").Invoke(Activator.CreateInstance(type), new object[] { "abc", 123 });
bool result = Convert.ToBoolean(obj);
未作任何异常处理,自行斟酌~