次の方法で共有


コンパイラ エラー CS0601

更新 : 2007 年 11 月

エラー メッセージ

Dllimport 属性を指定しているメソッドには static と extern を指定する必要があります。

正しいアクセス キーワードを持たないメソッドで DllImport 属性を使用しました。

次の例では CS0601 エラーが生成されます。

// CS0601.cs
using System.Runtime.InteropServices;
using System.Text;

public class C
{
   [DllImport("KERNEL32.DLL")]
   extern int GetCurDirectory(int bufSize, StringBuilder buf);   // CS0601
   // Try the following line instead:
   // static extern int GetCurDirectory(int bufSize, StringBuilder buf);
}

public class MainClass
{
   public static void Main ()
   {
   }
}