Is it possible to Add/Remove/Change an embedded resource in .NET DLL?

后端 未结 3 1537
后悔当初
后悔当初 2020-12-05 05:18

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?

Edit:<

3条回答
  •  遥遥无期
    2020-12-05 05:53

    Its so easy, just 3 lines of code. What you need is to reference mono.cecil.dll (google it!) and:

    var targetasmdef = AssemblyFactory.GetAssembly("My.dll");
    //May seach for the one you need
    targetasmdef.MainModule.Resources.RemoveAt(0);
    AssemblyFactory.SaveAssembly(targetasmdef, "My2.dll");
    

提交回复
热议问题