我想使用 MethodInfo,有没有办法将 Cecil 的 MethodDefinition 转换为 MethodInfo?
I want to work with MethodInfo, is there a way to cast Cecil's MethodDefinition to MethodInfo?
推荐答案不是 - 这两种结构虽然内容相似,但几乎没有任何关系.
No - the two structures, while similar in content, have almost nothing to do with each other.
引用 Google 上的此主题组:
To quote from this thread on Google Groups:
Cecil 不适用于 CLR 的反射 API;它有自己的内部模型,它自己加载所有程序集,绕过CLR的加载机制.
Cecil does not work with the CLR's Reflection APIs; it has its own internal model, and it loads all assemblies itself, bypassing the CLR's loading mechanism.
该线程提供了一些关于如何绕过这一事实的想法,但它也正确地指出,在大多数情况下,正确的答案是仅使用 CLR 的反射系统,如果这是您真正想要的.
That thread gives some ideas on how to get around this fact, but it also correctly states that in most cases the correct answer is to just use the CLR's Reflection system if that is what you really want.
更多推荐
我可以从 MethodDefinition (Cecil) 获取 MethodInfo 吗?
发布评论