托管Dll动态调用
来源:互联网 发布:富云软件科技有限公司 编辑:程序博客网 时间:2024/05/20 04:12
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;
using System.Data;
using System.Reflection;
namespace CallDll
{
class Program
{
static void Main(string[] args)
{//E:\learnProg\CSharp\DyCalledDll\DyCalledDll\bin\x64\Release\DyCalledDll.dll
Assembly ass = Assembly.LoadFile(args[0]);//这里是动态库的路径。
Type tp = ass.GetType("DyCalledDll.Class1");//dllType是你所需要调用的动态库文件的命名空间+类名(NameSpace.Class)
MethodInfo method = tp.GetMethod("SayHello");//需要执行的函数
object ob = Activator.CreateInstance(tp);//创建对象
method.Invoke(ob, null);//执行函数,后一个参数即为执行函数需要的参数,若无则为null。
}
}
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;
using System.Data;
using System.Reflection;
namespace CallDll
{
class Program
{
static void Main(string[] args)
{//E:\learnProg\CSharp\DyCalledDll\DyCalledDll\bin\x64\Release\DyCalledDll.dll
Assembly ass = Assembly.LoadFile(args[0]);//这里是动态库的路径。
Type tp = ass.GetType("DyCalledDll.Class1");//dllType是你所需要调用的动态库文件的命名空间+类名(NameSpace.Class)
MethodInfo method = tp.GetMethod("SayHello");//需要执行的函数
object ob = Activator.CreateInstance(tp);//创建对象
method.Invoke(ob, null);//执行函数,后一个参数即为执行函数需要的参数,若无则为null。
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace DyCalledDll
{
public class Class1
{
public void SayHello()
{
Console.WriteLine("Hello");
}
}
}
0 0
- 托管Dll动态调用
- 托管非托管Dll动态调用
- 托管非托管Dll动态调用
- 非托管Dll动态调用
- C#动态调用非托管DLL(一)
- C#动态调用非托管DLL(二)
- C#动态调用非托管DLL
- C#程序实现动态调用非托管的DLL文件
- C#程序实现动态调用非托管的DLL文件
- C#程序实现动态调用非托管的DLL文件
- C#程序实现动态调用非托管的DLL文件
- c#调用托管dll
- 托管调用非托管的DLL
- C#调用非托管DLL
- C#调用非托管DLL
- C#调用非托管Dll
- C#调用非托管DLL
- C#调用非托管DLL
- 代码学习心情日志20162-21
- java安全——数字签名+代码签名
- 【Memcached】基础知识-Cache
- java内存分析,栈内存,堆内存
- 欢迎使用CSDN-markdown编辑器
- 托管Dll动态调用
- UDL ODBC 获取数据库连接字符串
- JavaWeb----JDBC
- OpenCV学习06
- ImageView中src和background属性的主要亮点区别
- 计算机时间、unix时间、linux时间、java时间为何以1970年1月1日为原点?从1970年1月1日开始计算?
- 数据挖掘软件 clementine软件的基本操作
- Spark应用开发中使用缓存或checkpoint实现容错
- Java利用OpenOffice将word等office文档转换成PDF