Share via


컴파일러 오류 CS0601

업데이트: 2007년 11월

오류 메시지

DllImport 특성은 'static' 및 'extern'으로 표시된 메서드에만 지정할 수 있습니다.
The DllImport attribute must be specified on a method marked 'static' and '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 ()
   {
   }
}