Hi JB,
Can we create new Assembly "B" from a assembly "A" , where we can call
one method of " A" inside another method of "B".
Basically i want to use assembly "B" method as a blank body and call :
required method from assembly "A"
static MethodReference
GetSystemObjectEqualsMethodReference(AssemblyDefinition assembly)
{
var @object = assembly.MainModule.TypeSystem.Object.Resolve();
// assembly.Modules.First ( m => m.Name == "acc_check.exe")
Console.WriteLine(@object.Methods.ToString() );
return @object.Methods.First ( m => m.Name == "Check");
}
static MethodDefinition createMethod(ModuleDefinition md, TypeDefinition
td, AssemblyDefinition assembly)
{
var objectEqualsMethodReference =
assembly.MainModule.Import(GetSystemObjectEqualsMethodReference(assembly));
// var objectEqualsMethodReference =
assembly.MainModule.Import(ImportMethod("Check", md, td));
MethodDefinition newMethod = new
MethodDefinition("Check_Nested", MethodAttributes.Public |
MethodAttributes.HideBySig, md.Import(typeof (void)));
newMethod.Body.Instructions.Add(Instruction.Create(OpCodes.Nop));
newMethod.Body.Instructions.Add(Instruction.Create(OpCodes.Call,
objectEqualsMethodReference));
newMethod.Body.Instructions.Add(Instruction.Create(OpCodes.Pop));
newMethod.Body.Instructions.Add(Instruction.Create(OpCodes.Ret));
return newMethod;
}
Still error showing need to import method as it is in different assembly
~Thanks
--
--
--
mono-cecil
---
You received this message because you are subscribed to the Google Groups
"mono-cecil" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.