Sdílet prostřednictvím


Compilerwarnung (Stufe 1) CS0626

Aktualisiert: November 2007

Fehlermeldung

Die Methode, der Operator oder der Accessor "Methode" ist als extern markiert und enthält keine Attribute. Fügen Sie ein DllImport-Attribut hinzu, um die externe Implementierung anzugeben.
Method, operator, or accessor 'method' is marked external and has no attributes on it. Consider adding a DllImport attribute to specify the external implementation

Eine als extern markierte Methode sollte auch mit einem Attribut, z. B. dem DllImport-Attribut, markiert werden.

Das Attribut gibt an, wo die Methode implementiert ist. Das Programm benötigt zur Laufzeit diese Information.

Im folgenden Beispiel wird CS0626 generiert:

// CS0626.cs
// compile with: /warnaserror
using System.Runtime.InteropServices;

public class MyClass
{
   static extern public void mf(); // CS0626
   // try the following line
   // [DllImport("mydll.dll")] static extern public void mf();

   public static void Main()
   {
   }
}