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 M(); // CS0626
// try the following line
// [DllImport("mydll.dll")] static extern public void M();
public static void Main()
{
}
}
Collaborate with us on GitHub
The source for this content can be found on GitHub, where you can also create and review issues and pull requests. For more information, see our contributor guide.
Feedback
https://aka.ms/ContentUserFeedback.
Coming soon: Throughout 2024 we will be phasing out GitHub Issues as the feedback mechanism for content and replacing it with a new feedback system. For more information see:Submit and view feedback for