简体   繁体   English

哪些C#编译器错误没有记录?

[英]Which C# compiler errors are undocumented?

This is meant to be a collection of possible C# compiler errors that are not documented. 这是一个未记录的可能的C#编译器错误的集合。

If you encounter such an error, please post an answer here listing: 如果您遇到这样的错误,请在此处发布回答:

  • The error number (CS nnnn ) 错误号(CS nnnn
  • The associated error message 相关的错误消息
  • If possible, a small snippet of code that will produce the error 如果可能的话,会产生一小段代码,会产生错误

Example: 例:

CS0224: CS0224:

A method with vararg cannot be generic, be in a generic type, or have a params parameter 使用vararg的方法不能是通用的,可以是泛型类型,也可以是params参数

Produced by: 由。。。生产:

 int Foo<T>(__arglist) { return 0; } 

If someone has already posted an answer listing the error you encountered, then edit that answer to add additional details. 如果有人已发布列出您遇到的错误的答案,请编辑该答案以添加其他详细信息。

The list of documented errors can be found on MSDN . 可以在MSDN上找到记录的错误列表 There seem to be quite a few missing... 似乎有很多人失踪......

Found in the compiler string resource table but not in the MSDN Library index. 在编译器字符串资源表中找到,但在MSDN Library索引中找不到。 Many of them are surely obsolete, some smell like interesting undocumented features like support for modules and testing. 其中许多肯定是过时的,有些闻起来像有趣的无证功能,如支持模块和测试。 Checked up to CS2000: 检查CS2000:

CS0018: Operator 'xxx' not yet implemented CS0018:运营商'xxx'尚未实施
CS0240: 'xxx' cannot be both abstract and sealed (now CS0418) CS0240:'xxx'不能同时抽象和密封(现为CS0418)
CS0679: Other languages may permit the internal virtual member 'xxx' to be overridden CS0679:其他语言可能允许覆盖内部虚拟成员“xxx”
CS0767: Cannot inherit interface 'xxx' with the specified type parameters because it causes method 'yyy' to contain overloads which differ only on ref and out CS0767:无法使用指定的类型参数继承接口'xxx',因为它导致方法'yyy'包含仅在ref和out上有所不同的重载
CS0846: An expression tree may not contain a call or invocation that uses optional arguments CS0846:表达式树可能不包含使用可选参数的调用或调用
CS0847: An expression tree may not contain an indexed property CS0847:表达式树可能不包含索引属性
CS0848: Indexed property 'xxx' has non-optional arguments which must be provided CS0848:索引属性“xxx”具有必须提供的非可选参数
CS0849: Indexed property 'xxx' must have all arguments optional CS0849:索引属性“xxx”必须具有所有可选参数
CS0850: Partial declarations of 'xxx' must have the same type parameter names and variance modifiers in the same order CS0850:“xxx”的部分声明必须具有相同顺序的相同类型参数名称和方差修饰符
CS0851: Using 'is' to test compatibility with 'dynamic' is essentially identical to testing compatibility with 'object' and will succeed for all non-null values CS0851:使用'is'来测试与'dynamic'的兼容性与测试与'object'的兼容性基本相同,并且对所有非null值都是成功的
CS1114: Member 'yyy' on embedded interop type 'xxx' cannot be evaluated while debugging since it is never referenced in the program. CS1114:嵌入式互操作类型'xxx'上的成员'yyy'在调试时无法评估,因为它从未在程序中引用。 Consider casting the source object to type 'dynamic' first or building with the 'Embed Interop Types' property set to false when debugging 在调试时,请考虑首先将源对象强制转换为“dynamic”,或者将“Embed Interop Types”属性设置为false
CS1543: Added module 'xxx' has unresolved reference to type 'yyy' CS1543:添加模块'xxx'有未解析的类型'yyy'的引用
CS1544: Added module 'yyy' references module 'xxx' which was not added CS1544:添加了未添加的模块'yyy'引用模块'xxx'
CS1595: Delegate 'xxx' has some invalid arguments CS1595:委托'xxx'有一些无效的参数
CS1735: Ignoring /win32manifest for module because it only applies to assemblies CS1735:忽略/ win32manifest for module,因为它仅适用于程序集
CS1736: Cannot convert 'xxx' to delegate because some of the return types in the block are not implicitly convertible to the delegate return type CS1736:无法将'xxx'转换为委托,因为块中的某些返回类型不能隐式转换为委托返回类型
CS1737: Expected parameter CS1737:预期参数
CS1738: Named argument specifications must appear after all fixed arguments have been specified. CS1738:在指定了所有固定参数后,必须出现命名参数规范。 Please use language version 7.2 or greater to allow non-trailing main arguments. 请使用语言版本7.2或更高版本以允许非尾随主要参数。
CS1739: Filename given with /appconfig is too long or invalid. CS1739:/ appconfig给出的文件名太长或无效。 Re-purposed in Roslyn (C# v6) to: The best overload for 'M' does not have a parameter named 'x'. 在Roslyn(C#v6)中重新使用:'M'的最佳重载没有名为'x'的参数。
CS1903: Unrecognized value 'xxx' provided for '/test' option CS1903:为'/ test'选项提供了无法识别的值'xxx'
CS1904: 'xxx' is not a valid warning number CS1904:'xxx'不是有效的警告编号

CS0002: CS0002:

Unable to load message string from resources 无法从资源加载消息字符串

Produced by: 由。。。生产:

Most likely due to damage to the string table resource or a completely missing cscui.dll so it can't display any error messages. 很可能是由于字符串表资源损坏或完全丢失cscui.dll所以它无法显示任何错误消息。 Reference question is here . 参考问题在这里

CS1669: CS1669:

__arglist is not valid in this context __arglist在此上下文中无效

Produced by: 由。。。生产:

delegate int Bar(__arglist);

More like Leppie's example, found in the compiler string resource table and presumably triggered by undocumented keywords: 更像Leppie的例子,可以在编译器字符串资源表中找到,并且可能是由未记录的关键字触发的:

CS0190: The __arglist construct is valid only within a variable argument method CS0190:__ arglist构造仅在变量参数方法中有效
CS0224: A method with vararg cannot be generic, be in a generic type, or have a parameter array CS0224:使用vararg的方法不能是通用的,可以是泛型类型,也可以是参数数组
CS0257: An __arglist parameter must be the last parameter in a formal parameter list CS0257:__arglist参数必须是形式参数列表中的最后一个参数

CS1738: CS1738:

Named argument specifications must appear after all fixed arguments have been specified. 在指定了所有固定参数后,必须出现命名参数规范。 Please use language version 7.2 or greater to allow non-trailing main arguments. 请使用语言版本7.2或更高版本以允许非尾随主要参数。

Produced by 由。。。生产

string str = GetNewString(isAllowed: isUserAllowed, str);

Potential Solution: Upgrade to C# version 7.2 or greater 可能的解决方案:升级到C#7.2或更高版本

Right-click on the project to upgrade --> Properties --> Build --> Advanced --> Language version. 右键单击要升级的项目 - >属性 - >构建 - >高级 - >语言版本。

升级到C#的最新次要版本

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM