Mono.Cecil,缺少编译器所需的成员“System.Runtime.CompilerServices.ExtensionAttribute..ctor" [英] Mono.Cecil, Missing compiler required member 'System.Runtime.CompilerServices.ExtensionAttribute..ctor'

查看:11
本文介绍了Mono.Cecil,缺少编译器所需的成员“System.Runtime.CompilerServices.ExtensionAttribute..ctor"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我下载了最新的 Mono.Cecil,现在每当我启动我的项目时,它都会给我这个错误.如果我删除并添加 mono.cecil,它就会消失.但每次我打开我的项目时,这样做都很痛苦.

I downloaded the latest Mono.Cecil and now whenever I start up my project it gives me that error. It goes away if I remove and add mono.cecil. But that is a pain to do every time I open my project.

推荐答案

对于所有想要在内部使用扩展方法并因此声明自己的内部 System.Runtime 的 .NET 2.0 项目来说,这个问题是一个众所周知的问题.CompilerServices.ExtensionAttribute 允许这样做.

This issue is a well know problem for all .NET 2.0 Projects that want to use Extension Methods internally and therefore declare their own internal System.Runtime.CompilerServices.ExtensionAttribute to allow this.

解决这个问题有多种方法,如果您使用的是 .NET 3.5 或更高版本,只需编译带有 NET_3_5NET_4_0 定义的 Mono.Cecil.如果您的目标是 .NET 2,您可能会很幸运并且可以直接编译(这取决于一些编译器内部,绝对不是 csc 命令行或 MSBuild).如果不是,解决方法是从 2.0 Cecil 程序集(使用 Cecil 本身...)中删除所有出现的该属性(包括定义).

There are various ways around this problem, if you're using .NET 3.5 or higher, simply compile Mono.Cecil with NET_3_5 or NET_4_0 defined. If you're targeting .NET 2 you might be lucky and get it to compile (it depends on some compiler internals, definitely not the csc commandline or MSBuild) out of the box. If not, the workaround would be stripping all occurences of that Attribute (including the definition) from the 2.0 Cecil assembly (using Cecil itself...).

已经这样做了,这没什么大不了的.但是我觉得你的问题是另一个问题,所以请提供更多关于你正在使用/定位的 Mono 版本和 .NET 版本的详细信息.

I have already done this and it's not a big deal. However I feel your issue is a different one, so please provide a little more detail on the Mono Version and .NET version you're using/targeting.

这篇关于Mono.Cecil,缺少编译器所需的成员“System.Runtime.CompilerServices.ExtensionAttribute..ctor"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆