如何为Windows应用程序创建.dll? [英] how to create the .dll for windows application?

查看:70
本文介绍了如何为Windows应用程序创建.dll?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

早上好吗...





我在c#中创建了一个窗口应用项目..它'正在工作..现在我想为该项目中的每个表单创建一个dll。



如何为单个窗口表单创建dll'' ?如何组合所有dll并像一个项目一样使用..

解决方案

将程序集输出类型更改为类库。使用Visual Studio,它将位于项目属性应用程序选项卡中。删除入口点( Main ),也许还有它的类,但这只是因为它们不再需要。并且,最好重命名程序集的输出文件。



但是,你不必做任何事情:你应该明白任何应用程序类型的程序集都可以被引用为任何其他程序集。 基本上,在.NET中没有DLL,非DLL或EXE。这些只是通常的习惯文件名,并不重要。只有由一个或多个可执行模块组成的程序集,但Visual Studio每个程序集仅支持一个模块。 (但模块仍然存在,你可以通过Reflection检查它们。)



唯一真正重要的是组件中包含的类型及其成员,它们可以由 public 访问修饰符公开。然后,您可以引用此程序集并使用这些类型和成员。是否形式,没关系。什么。



是的,我建议将输出文件重命名为* .DLL,但只是为了帮助您避免意外,当有人试图将您的库作为应用程序执行时。如果你不删除入口点,它甚至会被执行,但这不是你的目的。



-SA

Good morning ever one...


i''m created a project of window application in c#..it''s working.. now i want to create a dll''s for each form in that project.

How to create the dll''s for individual window forms? how can combine all the dlls and use like a one project..

解决方案

Change assembly output type to "Class Library". With Visual Studio, it will be in project Properties, "Application" tab. Remove entry point (Main) and perhaps its class, but only because they won''t be needed. And, preferably, renamed the output file of the assembly.

However, you don''t have to do anything: you should understand that any application-type assembly can be referenced as any other assembly. Essentially, in .NET there are no DLLs, non-DLLs or EXEs. These are only usual customary file names which do not matter much. There are only assemblies made of one or more executable modules, but Visual Studio supports only one module per assembly. (But modules still exists, you can check them up by Reflection.)

The only thing which really matters is the types and their members contained in the assembly, which can be exposed by the public access modifiers. Then you can reference this assembly and use those types and members. Forms or not, it does not matter. Anything.

Yes, I advised to rename the output file to *.DLL, but only to help you to avoid accidents, when someone tries to execute your library as application. If you don''t remove the entry point, it will be even executed, but this is not your purpose.

—SA


这篇关于如何为Windows应用程序创建.dll?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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