本文介绍了C#使用来自DLL的虚空的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当dllname在字符串中时,如何执行dll中的void?
为了使其更清楚一点:

字符串thisdll ="testdll.dll";
UseDLLOrSomething(thisdll)//我不知道如何从STRING导入dll
anyvoid();//我不知道如何从外部dll调用函数

有谁知道该怎么做?

PS:对不起,英语不好,那是因为我是荷兰人.

How can i execute a void from a dll when the dllname is in a string?
To make it a little clear:

string thisdll = "testdll.dll";
UseDLLOrSomething(thisdll)//i don''t know how to import a dll from a STRING
anyvoid();//I don''t know how to call a function from a extern dll

does anyone know how to do this?

PS: sorry for bad english, that is becouse i am dutch.

推荐答案

System.Reflection.Assembly.LoadFile("ddlFile");



然后使用反射调用该方法. (您可能还需要通过反射来实例化一个类).

如果是Native(例如c/c ++),则需要通过DLLImport注册该函数.

http://msdn.microsoft.com/en-us/library/ms235282.aspx [ ^ ]



And then use reflection to call the method. (you may need to instance a class via reflection as well).

If it''s Native (like c/c++) then you''ll need to register the function via a DLLImport.

http://msdn.microsoft.com/en-us/library/ms235282.aspx[^]


这篇关于C#使用来自DLL的虚空的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-24 02:54