Avertissement du compilateur (niveau 1) CS0626
Mise à jour : novembre 2007
Message d'erreur
La méthode, l'opérateur ou l'accesseur 'méthode' est marqué comme external et n'a pas d'attribut. Si possible, ajoutez un attribut DllImport pour spécifier l'implémentation externe.
Method, operator, or accessor 'method' is marked external and has no attributes on it. Consider adding a DllImport attribute to specify the external implementation
Une méthode marquée comme extern doit également être marquée avec un attribut, par exemple, l'attribut DllImport.
L'attribut spécifie l'emplacement où la méthode est implémentée. Au moment de l'exécution, le programme a besoin de ces informations.
L'exemple suivant génère l'avertissement CS0626 :
// CS0626.cs
// compile with: /warnaserror
using System.Runtime.InteropServices;
public class MyClass
{
static extern public void M(); // CS0626
// try the following line
// [DllImport("mydll.dll")] static extern public void M();
public static void Main()
{
}
}