使用导入的DLL中的方法 [英] Using methods from an imported DLL

查看:79
本文介绍了使用导入的DLL中的方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我有一个第三方DLL,它没有在C#项目中添加为参考.
我创建了一个新的类项目,并使用现有项目"选项添加了该文件.
现在我想在我的项目中使用该文件的方法.
后来我想构建我的项目,然后将此项目DLL应用于新项目.
非常感谢

Hi All,

I have a thirdpart DLL which doesnt add as a reference in the C# project.
I have created a new class project and added that file using "Existing Item" option.
Now i want to use the methods of that file in my project.
And later on i want to build my project and then use this project DLL in to a new project.
Many thanks

推荐答案

此DLL可以是.NET程序集-任何类型的程序集都无所谓-也可以无关.如果它是.NET程序集,则可以将其添加为引用,但前提是引用的C#程序集的.NET框架和目标框架支持其目标版本.您还可以通过System.Reflection.Assembly动态加载它并创建所需的类型,请参见 http://msdn.microsoft.com/en-us/library/system.reflection.assembly.aspx [ http://en.wikipedia.org/Wiki/P/Invoke [ ^ ], http://msdn.microsoft.com/en-us/library/Aa712982 [ ^ ].

另外,请阅读此CodeProject文章:基本P/调用 [
This DLL can be a .NET assembly — any kind of assembly, does not matter — or not. If it is a .NET assembly, you can add it as a reference, but only if your .NET framework and target framework of your referencing C# assembly supports its target version. You can also dynamically load it and create its type(s) you need via System.Reflection.Assembly, see http://msdn.microsoft.com/en-us/library/system.reflection.assembly.aspx[^].

If this is not a .NET assembly, you have to use P/Invoke, see http://en.wikipedia.org/wiki/P/Invoke[^], http://msdn.microsoft.com/en-us/library/Aa712982[^].

Also, read this CodeProject article: Essential P/Invoke[^].

—SA


这篇关于使用导入的DLL中的方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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