从C#可执行文件调用C#DLL方法 [英] Calling a C# DLL method from a C# executable

查看:122
本文介绍了从C#可执行文件调用C#DLL方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,

我对C#比较新。我创建了一个包含许多方法的DLL。一种方法是应用程序驱动程序,而这反过来又将调用多种形式。我有一个单独的可执行文件,需要在DLL中调用此驱动程序方法。我怎么称呼这种方法? call语句的语法是什么?



问候

Pat

解决方案

谢谢SA,

并感谢参考资料,我将会阅读。我已经在我的.exe中设置了对DLL的引用但是我仍然不知道如何从我的.exe中调用DLL中的方法



can你能给我一个简单的例子。



问候

Pat


没有语法。你以与调用者完全相同的方式执行它,并且被调用的方法在同一个程序集中。构建应用程序时,需要引用程序集。



此时您还没有获得.NET基础知识。从本质上讲,.NET的构建块不是DLL或EXE,而是程序集,它是技术的核心。在你开始写任何东西之前,你需要学习一些关于它们的基础知识。请参阅:

http://en.wikipedia.org/wiki/Assembly_%28CLI %29 [ ^ ],

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

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

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



-SA

Hello,
I'm relatively new to C#. I have created a DLL which contains a number of methods. One method is the application driver and this in turn will in turn call a number of forms. I have a separate executable which needs to call this driver method within the DLL. How can I call this method ? What is the syntax of the call statement ?

regards
Pat

解决方案

Thanks SA,
and thanks for the references, which I will read. I have already set up the reference to the DLL in my .exe However I still don't know how to call a method within the DLL from my .exe

can you please give me a simple example.

regards
Pat


There is no syntax. You do it in exact same way as you caller and called method was in the same assembly. When you build the application, you will need to reference an assembly.

You are yet to get the .NET basics at this moment. Essentially, building blocks of .NET are not "DLLs" or "EXEs", but assemblies, a central point of technology. You need to learn some basics about them before you even start to write anything at all. Please see:
http://en.wikipedia.org/wiki/Assembly_%28CLI%29[^],
http://msdn.microsoft.com/en-us/library/ms173099.aspx[^],
http://msdn.microsoft.com/en-us/library/ms173102.aspx[^],
http://msdn.microsoft.com/en-us/library/ms173101.aspx[^].

—SA


这篇关于从C#可执行文件调用C#DLL方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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