正确的(最佳)DLL构建方法 [英] Correct (Best) DLL construction method

查看:72
本文介绍了正确的(最佳)DLL构建方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我过去制作过一些DLL,但我不确定它们是否正确制作.我在制作DLL项目方面经验不足,但是我为此目的所做的工作.我的问题是,构造DLL的最佳方法是什么?

I have made a few DLL's in the past but I'm not entirely sure they are made correctly. I don't have much experience at making DLL projects but what I did worked for its purpose. My question is, What is the best method for constructing a DLL?

我需要公开一些特定的变量,就像这样:

I need some particular variables to be public which I do like this:

Public Shared sVar01 As String = String.Empty
Public Shared bBol01 As Boolean = True
Public Shared sVar02 As String = String.Empty
Public Shared iInt01 As Integer = 0

是对DLL正确执行此操作还是应该使用属性来代替?我还看到了其他一些使用公共共享属性的示例.

Am doing this correctly for a DLL or should I use property instead? I have seen some other examples where Public Shared Properties have been used.

目的是从我的应用程序中捕获一些值,并在某些私有函数中使用它们.

The purpose is to capture some values from my application and use them in some Private Functions.

有没有我可以参考的标准类模板,以完全理解正确的构造过程?

Is there a standard class template that I can refer to to fully understand the correct construction procedure?

感谢任何帮助:)

Nacho

Nacho是Nigel& amp; amp; quot;真实事实!& amp; amp; quot;

Nacho is the derivative of Nigel "True fact!"

推荐答案

的派生

要创建DLL,您只需将一个新项目添加到类型为类库"的Visual Studio解决方案中即可. (如果您打算在Windows Phone或Xbox 360应用中使用代码,则为便携式类库".

To create a DLL you simply add a new project to your Visual Studio solution of type "Class library" (or "Portable Class Library" if you intend your code to be used in a Windows phone or Xbox 360 app).

然后,只需将类添加到DLL项目中,就如同添加其他任何.net应用程序一样.

Then you just add classes to your DLL project like you would any other .net application.

在另一个应用程序中,您只需添加一个引用(在解决方案资源管理器中右键单击引用",然后单击添加引用"),即可使用您在DLL中定义的类(无论如何都是公共类). DLL专案).一次 您已经完成了操作,就可以像在其他.Net类中一样使用在DLL中创建的类.

In another application, you can then use the classes you defined in your DLL (the public ones anyway) simply by adding a reference (Right-click on References in the Solution Explorer and click Add reference; then you can pick out your DLL project). Once you've done that you can just use the classes you created in your DLL like any other .Net class.


这篇关于正确的(最佳)DLL构建方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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