I know I can read an assembly and modify some IL of it, and then load
it using AssemblyFactory.CreateReflectionAssembly() method. However, I
want to modify a type which is already loaded in. Is there any way to
do that? For instance, I have the below code.
void SomeMethod()
{
SomeLib.SomeObject someObj = new SomeLib.SomeObject();
// Suppose SomeObject is defined in SomeAssembly.dll
// Here I add a bunch of code to read SomeAssembly.dll and modify
the behavior of SomeObject.SomeMethod.
AssemblyDefinition asmDef = AssemblyFactory.GetAssembly(@"C:
\SomeFolder\SomeAssembly.dll");
// Do modification...
// ...
// Then I am expecting a way to make the change work...so I try to
use CreateReflectionAssembly method...
Assembly asm = AssemblyFactory.CreateReflectionAssembly(asmDef);
// I am expecting someObj.SomeMethod() is changed, but in fact it
is NOT...
someObj.SomeMethod();
}
Apparently AssemblyFactory.CreateReflectionAssembly does not work, but
I can't find an appropriate method to do it...
Thanks a lot!
- Wang, Lie
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"mono-cecil" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/mono-cecil?hl=en
-~----------~----~----~----~------~----~------~--~---