Freigeben über


Compilerwarnung (Stufe 2) CS3021

"Typ" erfordert kein CLSCompliant-Attribut, da die Assembly kein CLSCompliant-Attribut aufweist.

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 als CLS-kompatibel deklariert, besteht keine Notwendigkeit, dass sich ein Element in der Assembly selbst als nicht kompatibel deklariert, da angenommen wird, dass keine Kompatibilität besteht. Weitere Informationen zu den CLS-Konformitätsregeln finden Sie unter Sprachunabhängigkeit und sprachunabhängige Komponenten.

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