문제

Say I have assembly A. It was modified with Mono.Cecil a little bit. Now 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 from assembly A with the one in assembly B. I tried a few things, but I know that for one of my attempts, it actually remapped a method call like this:

Console.WriteLine("Test.");

...into this:

int.WriteLine("Test.");

That can't be right. What is the correct way to replace a class with Mono.Cecil?

도움이 되었습니까?

해결책

You're probably doing something that Cecil doesn't understand. It's impossible to tell you what without seeing any code.

Swapping a type by another is not trivial, you'd have to recreate in the target module the object model you want to inject, and replace every reference of it with the new one. Basically, you'd have to walk over every reference in the target module and make sure it's properly processed.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top