如何嵌入引用dll文件? [英] how to embed reference dll file?

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

问题描述

我在同一个解决方案中有两个项目。项目A需要参考项目B.



在项目A调试文件夹中,有一个从项目B生成的DLL文件。



项目A.exe运行正常,如果它与这个dll文件在同一个折叠中,但它会得到错误按摩,未处理的异常......无法加载文件或程序集......,如果我将项目A.exe移动到另一个位置而不将这个dll文件移动到一起。



问题:有没有办法嵌入(我不确定这个术语)项目B dll文件进入Project A.exe,所以我不需要一直把它们放在一起吗?



感谢您的回答或提示:)

I have two projects in the same solution. Project A needs to refer to Project B.

In Project A debug folder, there is a dll file generated from Project B.

Project A.exe runs fine if it is in the same fold as this dll file, but it will get an error massage, "Unhandled exception……Could not load file or assembly……", if I move Project A.exe to another location without moving this dll file together.

Questions: is there a way to "embed" (I am not sure about this term) Project B dll file into Project A.exe, so I don’t need to keep them together all the time?

Thanks for your answer or hint:)

推荐答案





是的,这是可能的。

使用ILMerge:

http://research.microsoft.com/en-us/people /mbarnett/ILMerge.aspx [ ^ ]

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

您可以从这里下载:

http://www.microsoft.com/en-us/download/details.aspx?id=17630 [< a href =http://www.microsoft.com/en-us/download/details.aspx?id=17630target =_ blanktitle =新窗口> ^ ]
Hi,

Yes, it's possible.
Use ILMerge:
http://research.microsoft.com/en-us/people/mbarnett/ILMerge.aspx[^]
Merging .NET assemblies using ILMerge[^]
You can download it from here:
http://www.microsoft.com/en-us/download/details.aspx?id=17630[^]


而不是移动exe周围创建一个包含所需的所有依赖项的部署包(例如,这可能包括配置文件和其他资源)。



这是部署主题的起点 [ ^ ]

另一个一个值得注意的是这样的引用属性,确保设置了Copy Local = True
Instead of "moving" an exe around create a deployment package that contains all the dependent stuff you need (this might include config files and other resources for example).

Here's a starting point on deployment topics[^]
Another one to watch out for is on the properties for references like this ensure that Copy Local = True is set


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

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