如何制作和使用DLL [英] How to make and use a dll

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

问题描述

如何在C#中创建和使用dll ..

How to make and use a dll in C#..

推荐答案

要创建DLL,您需要在c#中创建一个类库项目,一旦编译就会创建DLL。



要使用DLL,您只需在项目中添加对DLL的引用



链接



http://msdn.microsoft.com/en-us/library/3707x96z%28v=vs.80%29.aspx [ ^ ]



http://stackoverflow.com/questions/9830127/referencing-a-dll- in-c-sharp [ ^ ]



http://msdn.microsoft.com/en-us/library/wkze6zky%28v=vs.80%29.aspx [ ^ ]
To create a DLL you need to create a class library project in c# which once compiled will create the DLL.

To use the DLL you just need to add a reference to the DLL in your project

Links

http://msdn.microsoft.com/en-us/library/3707x96z%28v=vs.80%29.aspx[^]

http://stackoverflow.com/questions/9830127/referencing-a-dll-in-c-sharp[^]

http://msdn.microsoft.com/en-us/library/wkze6zky%28v=vs.80%29.aspx[^]


在解决方案资源管理器窗格中右键单击您的解决方案,然后选择添加......新建项目

在出现的对话框中,选择C#作为语言左边,然后是右边的类库。

将底部的名称更改为描述DLL包含内容的内容:VideoControls或ImageSlideShow也许。

按确定。

您的解决方案中将添加一个新项目。

如果您想在同一解决方案中从其他项目访问它,然后右键单击每个项目名称下的引用,并选择添加引用。

在出现的对话框中,选择左侧的项目,在右侧突出显示您的DLL名称,然后按添加。关闭对话框。



要在外部项目中使用它,构建它以便发布并以正常方式添加它作为参考,浏览到发布版本的DLL。
Right click your solution in the Solution Explorer pane, and select "Add..."..."New Project"
In the dialog that appears, Select C# as the language on the left, then "Class Library" on the right.
Change the "Name" at the bottom to something that describes what the DLL is to contain: "VideoControls" or "ImageSlideShow" perhaps.
Press Ok.
A new project will have been added to your solution.
If you want to access it from your other projects in the same solution, then right click "References" under each project name, and select "Add Reference".
In the dialog that appears, select "projects" on the left hand side, highlight your DLL name on the right, and press "Add". The close the dialog.

To use it in external projects, build it for release and add it as a reference in the normal way, browsing to the release version of the DLL.


打开新项目作为类库,输入代码并构建它。



它将生成可重复使用的.dll文件如果您在基于Windows的应用程序中编写代码,请转到解决方案资源管理器选择您的应用程序右键单击它并选择属性,



你会看到输出类型你可以把它改成类库,

记得只建,如果你试着调试它就会抛出错误!





成功创建.dll文件后,您可以通过以下方式将其用于其他应用程序:

右键单击解决方案资源管理器上的应用程序,选择添加引用并浏览分配.dll的位置..
open new project as class library, type code and build it.

it will make reusable .dll file for you.
another way if you have written code in windows based application, go to solution explorer select your application right click it and select property,

you will see the output type you can change it to class library,
remember to build only, if you try to debug it it will throw an error!


After successfully creating a .dll file you can use it to another application by:
right click your application on solution explorer, select Add reference and browse where the .dll is allocated..


这篇关于如何制作和使用DLL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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