다음을 통해 공유


컴파일러 오류 CS0601

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 ()  
   {  
   }  
}