是否可以添加/删除/修改的.NET的DLL嵌入的资源? [英] Is it possible to Add/Remove/Change an embedded resource in .NET DLL?

查看:399
本文介绍了是否可以添加/删除/修改的.NET的DLL嵌入的资源?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以添加/删除/修改的一个.NET的DLL嵌入的资源已被编译后?如果是这样,这是怎么做的,以及是否有任何陷阱?

Is it possible to add/remove/change an embedded resource in a .NET DLL after it has been compiled? If so, how is this done, and are there any gotchas?

编辑:

我想手动做到这一点,但最终通过自动在生成后事件的脚本。

I would like to do this manually, but eventually automatically through a script in the post-build event.

推荐答案

有没有办法做到这一点在管理code 。一旦一个资源已经被嵌入它变得就像编译MSIL code中的组件的一部分是。

There's no way to do this in managed code. Once a resource has been embedded it becomes part of the assembly just like the compiled MSIL code is.

然而,您可以手动执行此操作,像<一个href="http://stackoverflow.com/questions/6545858/is-it-possible-to-add-remove-change-an-embedded-resource-in-net-dll/6546174#6546174">suggested通过卢塞罗,使用的 ILDASM ,消除资源使用文本编辑器,最后重新装配使用的 ILASM

However, you could do this manually, like suggested by Lucero, by disassembling the DLL into a text file using ildasm, removing the resource using a text editor, and finally reassembling the DLL using ilasm.

下面是一个使用一个单一的嵌入式文本文件中的DLL的例子:

Here's an example using a DLL with a single embedded text file:

1)反编译的DLL成MSIL:

1) Decompile the DLL into MSIL:

ildasm MyLibrary.dll /out=MyLibrary.il

2)打开生成的 MyLibrary.il 文件并删除 .mresource 部分:

.mresource public MyLibrary.MyResource.txt
{
  // Offset: 0x00000000 Length: 0x0000000F
  // WARNING: managed resource file MyLibrary.MyResource.txt created
}

3)从修改 MyLibrary.il 文件重新组装DLL:

3) Reassemble the DLL from the modified MyLibrary.il file:

ilasm MyLibrary.il /dll

这篇关于是否可以添加/删除/修改的.NET的DLL嵌入的资源?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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