Compiler Warning (level 1) CS0626
Collapse the table of content
Expand the table of content
Important This document may not represent best practices for current development, links to downloads and other resources may no longer be valid. Current recommended version can be found here. ArchiveDisclaimer

Compiler Warning (level 1) CS0626

Method, operator, or accessor 'method' is marked external and has no attributes on it. Consider adding a DllImport attribute to specify the external implementation

A method marked extern should also be marked with an attribute, for example, the DllImport attribute.

The attribute specifies where the method is implemented. At run time, the program will need this information.

The following sample generates CS0626:

// 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()
© 2015 Microsoft