Replacing the class with Mono.Cecil
Let's say I have assembly A. It has been modified by Mono.Cecil a bit. Now let's say I have assembly B. It has a class named SomeClass
. Assembly A also has a class named SomeClass
. Now I want to replace SomeClass
assembly A with assembly B. I tried a few things, but I know that for one of my attempts, it actually renamed the method call like this:
Console.WriteLine("Test.");
... in it:
int.WriteLine("Test.");
This is not true. What's the correct way to replace the class with Mono.Cecil?
source to share
You are probably doing what Cecil doesn't understand. Impossible to tell you that without seeing any code.
Swapping the type with another is not trivial, you will need to recreate in the target module the object model you want to inject and replace each reference to it with a new one. Basically, you will have to go through each link in the target module and make sure it is rendered correctly.
source to share