在调用程序集中嵌入我的DLL [英] Embedded my DLL in calling assembly

查看:75
本文介绍了在调用程序集中嵌入我的DLL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的朋友们,

我在当前的解决方案中创建了一个库项目。我想发布我正在使用的DLL文件的设置成为我的exe文件的一部分。我不希望它在客户端单独可见。请帮忙。

问候

解决方案

你可以使用ILMerge 将多个.NET程序集合并到一个.NET程序集中。



您可以使用来自以下文章的方法(在替代方案部分的文章底部还提到了一些其他方法):

从嵌入式资源加载DLL [ ^ ]



但是因为你的图书馆项目在同一个解决方案中你是什么可以做的就是编辑你的'csproj'文件,这样在'release'模式下你也可以编译库项目的类。

看起来如下:

< pre lang =xml> < ItemGroup 条件 = '


(配置)'=='发布' >
< ; 编译 包含 < span class =code-keyword> = relative-path-to-your-library-project \ * .cs >
< 链接 > %(RecursiveDir)%(文件名)%(扩展名)< /链接 >
< 可见 > false < / Visible >
< /编译 >
< / ItemGroup >


Dear Friends,
I have created a library project in my current solution. I want to publish the setup where the dll file I am using become the part of my exe file. I Don't want it to separately visible on the client side. Please help.
Regards

解决方案

You can use ILMerge to combine multiple .NET assemblies into a single .NET assembly.

You can use the approach from the following article (also there are some additional approaches mentioned at the bottom of the article under the 'Alternatives' section):
Load DLL From Embedded Resource[^]

But because your library project is in the same solution what you can do is just edit your 'csproj' file so that on 'release' mode you include the compiling of the library project's classes as well.
That would look something like the following:

<ItemGroup Condition=" '


(Configuration)' == 'Release' "> <Compile Include="relative-path-to-your-library-project\*.cs"> <Link>%(RecursiveDir)%(Filename)%(Extension)</Link> <Visible>false</Visible> </Compile> </ItemGroup>


这篇关于在调用程序集中嵌入我的DLL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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