更新:2007 年 11 月
错误消息
方法、运算符或访问器“method”被标记为 external 并且没有属性。请考虑添加 DllImport 属性以指定外部实现。
标记为 extern 的方法也应使用属性(如 DllImport 属性)进行标记。
属性指定在哪个位置实现方法。在运行时,程序将需要此信息。
下面的示例生成 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()
{
}
}