如何创建自己的dll并与他人共享 [英] How to create my own dll and share it with others

查看:79
本文介绍了如何创建自己的dll并与他人共享的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经用Google搜索这个东西,找到了很多解决方案;
我已经使用过类了,所以对此有所了解.现在我想使用自己的DLL.
创建完课程后,每个人都建议我做以下事情

转到命令行并键入以下内容.

CSC/target:library/out:MyFunctions.dll AddClass.cs
MultiClass.cs FactorialClass.cs

转到命令行选项/target:library,并要求C Sharp编译器/链接器输出DLL而不是EXE. DLL可以使用其他名称;例如,/out:MyFunctions.dll指示编译器输出名称为MyFunctionsLib的DLL.否则,它将使用第一个.cs文件中的默认名称.在这里,它是AddClass.dll.

我没有得到这个东西.任何人都可以帮助我理解这个东西.
在此先谢谢您.

I have googled this thing and found lots of solution;
I have already used class so have idea about that..now i want to use my own DLL.
After creating the class everyone suggest me to do the following

Go to the command line and type the following.

CSC /target:library /out:MyFunctions.dll AddClass.cs
MultiClass.cs FactorialClass.cs

Go to the command line option /target:library and ask the C Sharp Compiler/Linker to output a DLL instead of an EXE. It''s possible to have a different name for the DLL; for example, /out:MyFunctions.dll directs the compiler to output the DLL with the name MyFunctionsLib; otherwise, it will take the default name from the first .cs file. Here, it''s AddClass.dll.

I am not getting this above thing..can anyone please help me understand this thing.
Thanks in advance.

推荐答案

您好,

若要生成文件MyFunctions.DLL,请使用以下命令行编译两个文件Add.cs和Mult.cs:
Hello ,

To build the file MyFunctions.DLL, compile the two files Add.cs and Mult.cs using the following command line:
csc /target:library /out:MyFunctions.DLL Add.cs Mult.cs


/target:library编译器选项告诉编译器输出DLL而不是EXE文件. /out编译器选项后跟一个文件名,用于指定DLL文件名.否则,编译器将使用第一个文件(Add.cs)作为DLL的名称.

要生成可执行文件TestCode.exe,请使用以下命令行:


The /target:library compiler option tells the compiler to output a DLL instead of an EXE file. The /out compiler option followed by a file name is used to specify the DLL file name. Otherwise, the compiler uses the first file (Add.cs) as the name of the DLL.

To build the executable file, TestCode.exe, use the following command line:

csc /out:TestCode.exe /reference:MyFunctions.DLL TestCode.cs


/out编译器选项告诉编译器输出EXE文件并指定输出文件的名称(TestCode.exe).此编译器选项是可选的. /reference编译器选项指定此程序使用的DLL文件.

请参考URL( http://msdn.microsoft.com/zh-CN /library/3707x96z(v=vs.80).aspx [ ^ ])以获取更多详细信息


The /out compiler option tells the compiler to output an EXE file and specifies the name of the output file (TestCode.exe). This compiler option is optional. The /reference compiler option specifies the DLL file or files that this program uses.

Please refer URL (http://msdn.microsoft.com/en-us/library/3707x96z(v=vs.80).aspx[^]) for more details


如果您使用的是Visual Studio,则可以按照以下步骤操作:
1.打开您的项目.
2.转到您的解决方案资源管理器.
3.右键单击您的项目名称,然后选择属性"选项卡.
4.转到应用程序"选项卡,然后找到输出类型"选项.
5.单击输出类型,然后选择类库.
6.保存并关闭属性窗口.
7.构建项目,您将在项目的调试文件夹中找到dll文件.
8.现在,您可以将dll合作并进行投影或将其包含在所需的任何项目中.
If you are using Visual Studio you can do by following steps:
1. Open your project.
2. Go to your solution explorer.
3. Right click on your project name and select properties tab.
4. Go to Application tab and find ''output type'' option.
5. Click on output type and select class library.
6. Save and Close properties window.
7. Build your project you will find dll files in debug folder of your project.
8. Now you can coopy your dll to and project or include them in any project you want.


Prashant提供了从命令行执行此解决方案的解决方案.我仍然不明白为什么您不使用IDE.如果要使用IDE进行相同的操作,请参考以下解决方案:

http://www.c-sharpcorner.com/UploadFile/mahesh/dll12222005064058AM/dll.aspx [ ^ ]
Prashant has given the solution to do it from command line. I still don''t understand why would you not use the IDE. In case you want to use the IDE to do the same refer to the following solution:

http://www.c-sharpcorner.com/UploadFile/mahesh/dll12222005064058AM/dll.aspx[^]


这篇关于如何创建自己的dll并与他人共享的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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