给加引用后如何调用dll文件 [英] How to call the dll file, after giving add reference

查看:182
本文介绍了给加引用后如何调用dll文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已通过添加引用将dll文件添加到我的项目中.现在,我想使用该dll文件....

I have added the dll file into my project by add reference. Now I wanted to use that dll file....

推荐答案

因此,请执行以下操作:
键入DLL中的类的名称,然后在末尾出现一条红线.
将鼠标悬停在其上,然后单击出现的下拉菜单.
它将为您提供添加适当的Imports语句的选项,然后就可以使用.
So do:
Type the name of a class that is within the DLL, and a red line will appear at the end.
Hover the mouse over it, and click on the drop down that appears.
It will give you the option of adding the appropriate Imports statement, and off you go.


您可以将反射与Activator类一起使用.使用激活器类创建dll中存在的类的实例,然后调用方法.

我在博客中提供了一种解决方案: http://tarundotnet.wordpress .com/2011/06/30/how-to-dynamic-load-assemblies/ [ http://www.developerfusion.com/tools/convert/csharp-to-vb/ [ http://stackoverflow.com/questions/2172826/call-运行时方法 [ ^ ]

希望能有所帮助. :thumbsup:
You can use reflection together with the Activator class. Use the activator class to create the instance of the class present in the dll and then invoke the methods.

I have provided a solution here in my blog : http://tarundotnet.wordpress.com/2011/06/30/how-to-dynamically-load-assemblies/[^] .
The code is in C Sharp but you can use this converter to convert to VB.NET : http://www.developerfusion.com/tools/convert/csharp-to-vb/[^]

You can also have a look at this discussion : http://stackoverflow.com/questions/2172826/call-method-at-runtime[^]

Hope it helped. :thumbsup:


如果您添加了引用,则您的项目具有新的类,您可以在添加dll的命名空间后创建这些类(假设它不是COM,如果是的话) s COM,对于每个暴露的对象,您都有一个代理类.然后,您可以正常创建对象.
IF you added a reference, your project has new classes, which you can create after adding the namespace of your dll ( assuming it''s not COM, if it''s COM, you got a proxy class per object exposed ). Then you can create objects as normal.


这篇关于给加引用后如何调用dll文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆