是否可以添加/删除/修改的一个.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.
然而,您可以手动执行此操作,像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
相关推荐
最新文章