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 ()
{
}
}
GitHub에서 Microsoft와 공동 작업
이 콘텐츠의 원본은 GitHub에서 찾을 수 있으며, 여기서 문제와 끌어오기 요청을 만들고 검토할 수도 있습니다. 자세한 내용은 참여자 가이드를 참조하세요.
.NET