更新:2007 年 11 月
错误消息
由于程序集没有 CLSCompliant 属性,因此“type”不需要 CLSCompliant 属性如果 [CLSCompliant(false)] 出现在程序集中的类上,而该程序集没有将程序集级 CLSCompliant 属性设置为 true(即行 [assembly: CLSCompliant(true)]),则会出现此警告。由于程序集没有声明自身符合 CLS,因此程序集中的任何对象均不需要声明自身不符合 CLS,因为已假定不符合 CLS。有关 CLS 遵从性的更多信息,请参见
若要消除此警告,请移除该属性或添加程序集级属性。
示例
下面的示例生成 CS3021:
复制代码 | |
---|---|
// CS3021.cs using System; // Uncomment the following line to declare the assembly CLS Compliant, // and avoid the warning without removing the attribute on the class. //[assembly: CLSCompliant(true)] // Remove the next line to avoid the warning. [CLSCompliant(false)] // CS3021 public class C { public static void Main() { } } |