【发布时间】:2011-02-04 15:31:13
【问题描述】:
如何通过名称获取基类方法的 MethodReference?
我试过了
type.BaseType.Resolve().Methods;
如果我将包含基类的 dll 添加到 assemblyresolver,它会返回方法。 但是,如果我使用
添加呼叫MSILWorker.Create(OpCodes.Call, baseMethod);
(其中 baseMethod 是通过从已解析的 TypeDefinition 中搜索方法找到的) 生成的 IL 不可读,甚至 Reflector 冻结并退出。
现在一些 IL:
如果在类型上调用私有方法:
call instance void SomeNamespace.MyClass::RaisePropertyChanged(string)
如果在基类型上调用受保护的方法:
call instance void [OtherAssembly]BaseNamespace.BaseClass::RaisePropertyChanged(string)
那么,如何使用 Mono.Cecil 生成后者?
【问题讨论】:
标签: inheritance assemblies cil il mono.cecil