如何创建DLL文件 [英] How to create DLL Files

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

问题描述

大家好吧

im这些天有严重的问题

我正在建立一个项目,但我必须再次编写所有代码,当我使用该代码时

在不同的项目中。

此外我的代码也不安全。

我听说过在.net制作你自己的dll文件

不仅允许你一次又一次地使用它,而且它也为你的代码提供了安全性。



任何人都可以帮我解决这个如何制作dll文件。在.net 2.0或以上。



任何形式的帮助都将受到高度赞赏....



谢谢

Hi everybody
i m having serious problem these days
I m building a project but i have to write all code again and when i use that code
in different project.
Moreover my code is not secure too.
I have heard about making your own dll files in .net which
not only allows you to use it again and againn but also it provides security to your code too.

Can anyone help me out in this how to make dll files. in .net 2.0 or above.

Any kind of help will be highly appreciated....

Thanks

推荐答案

在visual studio中,创建一个类库项目。这将在您编译时生成DLL。



创建DLL不会保护您的代码(如果您正在谈论逆向工程)。事实上,你可以做的就是完全保护你的.Net代码。
In visual studio, create a "Class library" project. This will result in a DLL when you compile.

Creating a DLL doesn't protect your code (if you're talking about reverse engineering). In fact, NOTHING you can do will completely protect your .Net code.


要添加到John Simmons的答案,当你开始构建DLL时,最简单的方法就是设置一个解决方案。有一个项目的dll和另一个项目的实际exe(或测试人员,如果你喜欢)。



在可执行项目中添加对dll项目的引用。这样你就可以修改dll,看看'调用端'发生了什么。
To add to John Simmons answer, when you start building a DLL, it's perhaps easiest to set up a solution where you have one project for the dll and another project for the actual exe (or tester if you like).

In the executable project add a reference to the dll project. This way you can make modifications to the dll and see what's happening on the 'calling side'.


如果你只是听说过在应用程序开发一段时间后编写DLL,你需要认真重新思考你的学习和工作方法。在您清楚了解基本平台功能和技术之前,请不要继续开发。 DLL就是这样的基本功能之一。



首先需要了解的是,.NET代码的主要构建块是Assembly,而不是DLL,它只是一个文件延期。在.NET中,.EXE和.DLL之间没有根本区别。通常.EXE用作应用程序的主要可执行模块,而.DLL用作要由其他程序集(应用程序或库)引用的类库的主要可执行模块。但是您可以使用.EXE文件并以与库完全相同的方式引用它。您可以使用备用主机来运行.NET应用程序,这需要具有与自定义EXE不同的结构的DLL。 EXE的唯一区别是有一个入口点(通常 Main ,但可以更改)。



类库用于提供代码重用,而不是用于保护。他们根本无法添加任何保护。通常,在同一应用程序域中使用的程序集之间的边界非常薄,以至于您几乎感觉不到它们。相比之下,应用域和流程是强烈孤立的。



-SA
If you only "have heard" about writing DLLs after some time of application development, you need seriously rethink your methods of learning and work. Don't proceed with development until you have clear understanding of basic platform capabilities and techniques. DLLs is one of such basic features.

First thing you need to understand, the major building block of .NET code is Assembly, not DLL, which is only a file extension. In .NET, there is not fundamental difference between .EXE and .DLL. Usually .EXE is used as a main executable module of an application, and a .DLL as a main executable module of a class library to be referenced by other assemblies (applications or libraries). But you can use .EXE file and reference it exactly the same way as a library. You can have an alternative host for running .NET application which would require DLLs with different structure than custom EXEs. The only difference of EXE is having an entry point (usually Main, but it can be changed).

Class libraries are used to provide code reuse, not for protection. They cannot add any protection at all. In general, boundaries between assemblies used in the same application domain are so thin that you hardly can feel them. In contrast, Application Domains and, hence, processes are strongly isolated.

—SA


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

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