Share via


Avertissement du compilateur (niveau 2) CS3021

Mise à jour : novembre 2007

Message d'erreur

'type' n'a pas besoin d'un attribut CLSCompliant, car l'assembly n'a pas d'attribut CLSCompliant
'type' does not need a CLSCompliant attribute because the assembly does not have a CLSCompliant attribute

Cet avertissement se produit si [CLSCompliant(false)] apparaît sur une classe d'assembly qui ne contient pas de valeur true pour l'attribut CLSCompliant (c.-à-d., la ligne [assembly: CLSCompliant(true)]). Puisque l'assembly ne se déclare pas conforme CLS, il n'est pas nécessaire que les éléments contenus dans l'assembly se déclarent non conformes, car ils sont supposés être non conformes. Pour plus d'informations sur la conformité CLS, consultez Écriture d'un code conforme CLS.

Pour supprimer cet avertissement, supprimez l'attribut ou ajoutez l'attribut au niveau de l'assembly.

Exemple

L'exemple suivant génère l'erreur 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()
    {
    }
}

Voir aussi

Concepts

Spécification CLS (Common Language Specification)