简体   繁体   English

如何创建一个包含所有其他DLL的文件?

[英]How to create a dll that includes all the others?

At the moment of creating a project of type "Library of Classes, usually one can generate a dll when compiling, but how could I generate a dll without losing others that I already have included? 在创建“类库”类型的项目时,通常一个人在编译时可以生成一个dll,但是如何生成一个dll而又不会丢失我已经包含的其他文件?

I explain with an example: It turns out that Nuget downloaded an S22.Imap dll with the one I worked with, later I generated the dll in the traditional way that I explained in the beginning, but when I wanted to work with dll in another computer, I got errors that were not I found functions that contained the S22.IMAP dll. 我以一个示例进行说明:事实证明,Nuget用我使用的那个下载了一个S22.Imap dll,后来我以我一开始所解释的传统方式生成了该dll,但是当我想在另一个版本中使用dll时在计算机上,出现的错误不是我发现的包含S22.IMAP dll的函数。 So to solve this problem, I had to copy the dll of my project, S22.IMAP in an additional way in a specific path of the other computer. 因此,要解决此问题,我必须以另一种方式在另一台计算机的特定路径中复制项目S22.IMAP的dll。

在此处输入图片说明

My question is: 我的问题是:

How could you generate a dll that includes the ones included in the project you were working with? 您如何生成一个包含正在使用的项目中包含的dll的dll?

In general, you don't . 一般来说, 您不会 A DLL is a dynamic linked library, and you would normally only combine static libraries during a build. DLL是动态链接库,通常在构建过程中只组合静态库。 Here is an answer on the difference between static and dynamic linking . 这是静态链接和动态链接之间区别答案

Typically you would include all the DLLs you need in the installer package. 通常,您会在安装程序包中包含所需的所有DLL。 If you use Visual Studio to create the installer, it can detect the dependencies for you. 如果使用Visual Studio创建安装程序,则它可以为您检测依赖项。 When you run the installer, all of the necessary DLLs are deployed. 运行安装程序时,将部署所有必需的DLL。 Nearly all commercial .NET software follows this pattern. 几乎所有的商业.NET软件都遵循这种模式。

It is possible to merge an assembly into another assembly using a tool called ILMerge . 可以使用称为ILMerge的工具将部件合并到另一个部件中。 This would be a very unusual thing to do, and could cause issues with intellectual property and code signing, so it is not recommended. 这将是非常不寻常的事情,并且可能导致知识产权和代码签名问题,因此不建议这样做。

All the referred 3rd party dlls (S22.Imap.dll in your example) will be copied to the output folder together with your own dll file (let's say a.dll) when you build your project. 在构建项目时,所有引用的第三方dll(在您的示例中为S22.Imap.dll)将与您自己的dll文件(例如a.dll)一起复制到输出文件夹中。 That means you should always copy them together (S22 + a.dll) to the place you want to refer them, on another computer/folder/place. 这意味着您应该始终将它们一起复制(S22 + a.dll)到要在另一台计算机/文件夹/位置上引用它们的位置。

If you really want to make them only one file (although it is not recommended), you can set the S22 one as some "nested resource". 如果确实只想使它们成为一个文件(尽管不建议这样做),则可以将S22设置为某个“嵌套资源”。 Then you will get only one a.dll file and the S22 one is inside the a.dll. 然后,您将只获得一个a.dll文件,而S22一个文件位于a.dll中。 See below page for some reference: 请参阅下页以获取一些参考:

Embedding one dll inside another as an embedded resource and then calling it from my code 将一个dll作为嵌入式资源嵌入到另一个dll中,然后从我的代码中调用它

AND, ILMerge is some tool that can help you do so. 而且, ILMerge是可以帮助您完成此任务的一些工具。

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

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