简体   繁体   English

创建可恢复代码的过程

[英]Process for creating resuable code

I have many C# applications that require a newly coded security protocol I wrote. 我有许多C#应用程序都需要我编写的新编码的安全协议。 There are many classes associated with the protocol, and it is not necessary to view the code at this point by the protocol caller, assuming proper documentation. 与协议相关的类很多,并且在假定适当的文档的情况下,协议调用者此时无需查看代码。

I think the process is to create a class library after reviewing Microsoft's Designing for Extensibility but I have never done this before. 我认为该过程是在查看Microsoft的“可扩展性设计”之后创建一个类库,但是我以前从未这样做过。 Can some one outline the proper process for this from creation of the library to implementation of the library? 有人可以概述从创建库到实现库的正确过程吗? If the answer is not creating a class library, can some one provide a reference detailing process, including requirements? 如果答案不是创建类库,那么有人可以提供参考详细过程,包括要求吗?

  1. Create a new project. 创建一个新项目。
  2. Use "class library" as the type of the project in visual studio. 在Visual Studio中使用“类库”作为项目的类型。 (You can change a project to this type after creation in the project properties as well). (您也可以在项目属性中创建后将项目更改为这种类型)。
  3. Put your classes in that project. 将您的课程放到该项目中。
  4. Other projects then need to reference it. 然后其他项目需要引用它。 If they are in the same solution just "add reference" and choose the other projects from the "projects" tab. 如果它们在同一解决方案中,则只需“添加引用”,然后从“项目”选项卡中选择其他项目。 If not in the same solution: 如果不在同一解决方案中:
    1. Build the class library. Build类库。
    2. Go to bin -> debug folder for that project 转到bin->该项目的调试文件夹
    3. Place the .dll file in some common location (possibly the GAC). 将.dll文件放在某个常见的位置(可能是GAC)。
    4. Add a reference to that .dll file from all projects that need to use it. 从需要使用它的所有项目中添加对该.dll文件的引用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM