我可以从 MethodDefinition (Cecil) 获取 MethodInfo 吗?

编程入门 行业动态 更新时间:2024-10-26 10:28:53
本文介绍了我可以从 MethodDefinition (Cecil) 获取 MethodInfo 吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我想使用 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 吗?

本文发布于:2023-11-05 04:18:06,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1559881.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:MethodDefinition   Cecil   MethodInfo

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!