How to add resource to existing signed assembly

蹲街弑〆低调 提交于 2020-01-15 01:49:16

问题


Given: - an assembly (e.g. "SomeLib.dll") - a text file (e.g. "myconfig.xml")

I need to embed the file myconfig.xml into the existing assembly SomeLib.dll

Please consider before pressing "Answer": I know about resources embeding during compile (csc.exe .. /embedresource:file ... ).

The thing is that I need to embed a resource after assembly has created.

Is it possible?

I also know about ILMerge. But havn't found how it could help.


回答1:


You can use Cecil for this: load an assembly, add a resource, save to an assembly.




回答2:


Your going to need to resign the assembly after adding the resource. The whole point of assembly signing is to prevent people from modifying the contents of an assembly without being able to tell it was modified. You can use signcode.exe, http://msdn.microsoft.com/en-us/library/9sh96ycy(VS.80).aspx to resign the assembly after adding the resource, assuming you have the proper certificates.




回答3:


The Assembly Linker tool can be used to combine modules and resources into a signed assembly. However, I have not been able to find a way to use an existing assembly as input.

> al.exe SomeLib.module /out:SomeLib.dll /keyfile:SomeLib.snk /embed:myconfig.xml



回答4:


You might be able to use Resource Hacker to automate the modification of assembly from command line (their tutorial includes samples how to automate). After the modification you just have to resign the assembly.



来源:https://stackoverflow.com/questions/783885/how-to-add-resource-to-existing-signed-assembly

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!