从 DLL 调用函数? [英] Call function from DLL?
本文介绍了从 DLL 调用函数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我是 C# 新手,我正在尝试学习 DLL 的使用.我正在尝试将我的对象包装在一个 DLL 中,然后在我的程序中使用它.
I'm new to C# and I'm trying to learn to usage of DLLs. I'm trying to wrap my objects in a DLL, and then use it in my program.
public class Foo // its in the DLL
{
public void Bar()
{
SomeMethodInMyProgram();
}
}
所以我尝试将它打包到一个 DLL 中,但我不能,因为编译器不知道 SomeMethodInMyProgram() 是什么.
So I try to pack this to a DLL but I can't, because compiler doesn't know what the SomeMethodInMyProgram() is.
我想像这样使用它:
class Program // my program, using DLL
{
static void Main(string[] args)
{
Foo test = new Foo();
test.Bar();
}
}
推荐答案
通过解决方案资源管理器添加 DLL - 右键单击引用 --> 添加引用,然后浏览"到您的 DLL - 然后它应该可用.
Add the DLL via the solution explorer - right click on references --> add reference then "Browse" to your DLL - then it should be available.
这篇关于从 DLL 调用函数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文