Freigeben über


Compilerwarnung (Stufe 2) CS3021

Aktualisiert: November 2007

Fehlermeldung

"Typ" erfordert kein CLSCompliant-Attribut, da die Assembly kein CLSCompliant-Attribut aufweist.
'type' does not need a CLSCompliant attribute because the assembly does not have a CLSCompliant attribute

Diese Warnung tritt auf, wenn [CLSCompliant(false)] bei einer Klasse in einer Assembly angegeben ist, für die das Attribut CLSCompliant auf Assemblyebene nicht auf true festgelegt ist (also die Zeile [assembly: CLSCompliant(true)] fehlt). Da sich die Assembly nicht selbst CLS-kompatibel deklariert, besteht keine Notwendigkeit, dass sich irgendetwas in der Assembly selbst als nicht kompatibel deklariert, da angenommen wird, dass keine Kompatibilität besteht. Weitere Informationen über die CLS-Kompatibilität finden Sie unter Schreiben von CLS-kompatiblem Code.

Damit diese Warnung nicht mehr angezeigt wird, entfernen Sie das Attribut, oder fügen Sie das Attribut auf Assemblyebene hinzu.

Beispiel

Im folgenden Beispiel wird CS3021 generiert:

// 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()
    {
    }
}

Siehe auch

Konzepte

CLS (Common Language Specification)