如何在没有任何封闭的dll文件的情况下构建单个EXE文件? [英] How to build a single EXE file only without any enclosed dll files?

查看:84
本文介绍了如何在没有任何封闭的dll文件的情况下构建单个EXE文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道我们是否只能在没有任何库文件的情况下构建单个EXE文件,例如dll文件?

在构建庞大而复杂的应用程序时,这是有用且必要的。但我的应用程序足够小,只能构建为单个EXE文件,我使用自己的库(大小约为13KB)编写我的应用程序,起初我认为在构建时,编译器会在我的应用程序中包含该库但是它没有。你能告诉我如何在建造时将它包含在我的应用程序中吗?我不想重写代码(另外,它涉及我在我的应用程序中使用的控件,它正是我的自定义TextBox)

非常感谢你!

I wonder if we can build a single EXE file only without any library files going with it such as dll files?
When building a huge and complex application, that's useful and necessary. But my application is small enough to build as a single EXE file only, I have used my own library (its size is about 13KB) to write my application, at first I thought when building, the compiler will include that library in my application but it doesn't. Could you please tell me how I can include it in my application when building? I don't want to rewrite code (plus, it concerns my controls I have used in my app, it's exactly my custom TextBox)
Thank you so much!

推荐答案

您需要ILMerge。请注意,这只有在dll是dll管理的情况下才有可能。



查看以下CodeProject文章解释这一点:



使用ILMerge合并.NET程序集 [ ^ ]



编辑:<一个DLL可以是一个基于.net的dll(托管dll - 一个带有CLR头)或一个标准DLL(例如mscorlib.dll,kernel32.dll,一个例子是mscorlib.dll,kernel32.dll, user32.dll等)。以下是SO的链接,讨论了基于CLR的dll



http://stackoverflow.com/questions/330032/checking-if-a-file-is-a-net-assembly [ ^ ]



正如Pete O'Hanlon所说,您可能还会将类库中的所有源文件(或单独的必需文件)包含到您的项目中,这样您就不需要了额外的DLL。



希望这会有所帮助!
You need ILMerge. Note that this is possible only if the dll's are managed dll's.

Check out the following CodeProject article that explains this:

Merging .NET assemblies using ILMerge[^]



A DLL could either be a .net based dll (managed dll - one with CLR header) or a standard DLL (an example is mscorlib.dll, kernel32.dll,user32.dll etc). Following is a link to SO, that discusses about CLR based dll's

http://stackoverflow.com/questions/330032/checking-if-a-file-is-a-net-assembly[^]

As Pete O'Hanlon said, you may also include all of the source files(or the required ones alone) in your class library to your project so that you don't need an additional DLL.

Hope this helps!


如果你担心的是你的应用程序中包含的功能,那么您只需将代码文件作为链接代码添加到项目中即可。通过从项目中选择添加现有项,并从插入按钮下拉列表中选择插入链接,这很容易做到这一点。通过这样做,您可以将实际的源文件添加到项目中。
If all you're worried about is including the functionality inside your application, then you could simply add the code files into your project as linked code. It's easy enough to do this, by choosing Add existing item from the project, and choose Insert as Link from the Insert button dropdown. By doing this, you can add the actual source files into your project.


[回答后续问题]



谢谢SA的明确解释!但即使我喜欢这样,我怎样才能将我的自定义文本框拖放和删除到我的表单上?我只能通过使用代码创建它的实例,但它在我的表单上的位置在哪里?我还要使用代码(使用Location属性),但这是我想要的位置吗?这太难了!另外,我有大约200个这样的自定义 TextBox 的实例,我认为在设计时将它们拖放到我的表单上是最简单,最可行的方法,没有其他方法可以去做。能不能给我更多建议来解决我的问题?非常感谢你!
不,这只是演示设计师有多酷的最简单方法。 :-)对于一个严肃的应用程序这样的风格只会减慢你的速度;并且最终结果可能永远不会实现。您需要更彻底地设计UI。



请尝试使用我的(不完整)指示列表以获得更好的UI设计:

< a href =http://www.codeproject.com/Answers/151247/GUI-Apperance-Csharp-Net.aspx> GUI外观 - C#.Net [ ^ ],

当屏幕分辨率发生变化时,Zom Out出现故障 [ ^ ],

类实现背后的代码 [ ^ ]。



这里有一个重要方面:永远不要使用绝对定位。始终将Dock与Padding和/或Margins结合使用。不要假设任何东西的固定尺寸。不要在一个容器中创建多个控件。如果有太多,它们属于 UserControl 或不同的视图。隐藏当前未使用的控件 - 用户也不希望看到太多。这方面可以在我上面引用的一个解决方案中解释。



-SA
[Answering a follow-up Question]

Thank you SA for the clear explanation! But even when I do like that, how can I "DRAG" and "DROP" my custom text box onto my form? I can only create an instance of it by using code, but where is its position on my form? I have also to use code (use Location property), but is it exactly a position I want? It is too difficult to do! Plus I have about 200 such instances of my custom TextBox and I think dragging and dropping them onto my form at design time is the easiest and the most feasible way, no other way to do that. Could you please give me more suggestions to solve my problem? Thank you so much!
No, it only the easiest way to demonstrate how cool the Designer is. :-) For a serious application such style only slows you down; and the final result may never be achieved. You need to design UI more thoroughly.

Please try to use the list of my (incomplete) directions for better UI design:
GUI Apperance - C#.Net[^],
Zom Out malfunctions when Screen resolution changes[^],
Code behind class implementation[^].

One important aspect here: never use absolute positioning. Always use Dock in combination with Padding and/or Margins. Do not assume fixed sizes of anything. Do not create multiple controls in one container. If there are too many, they belong to a UserControl or a different view. Hide controls which are not currently used — the user also does not want to see too many. This aspect is explain in one of my Solutions referenced above.

—SA


这篇关于如何在没有任何封闭的dll文件的情况下构建单个EXE文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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