Microsoft MVP성태의 닷넷 이야기
글쓴 사람
정성태 (techsharer at outlook.com)
홈페이지
첨부 파일
 

error CS5001: Program does not contain a static 'Main' method suitable for an entry point

지난 글의 예제를,

C# 9 최상위 문에 STAThread 사용
; https://www.sysnet.pe.kr/2/0/12623

.NET Framework 4.0 대상의 C# 9.0 컴파일러로 실습하면 이런 오류가 발생합니다.

Rebuild started...
1>------ Rebuild All started: Project: ConsoleApp1, Configuration: Debug Any CPU ------
1>C:\temp\ConsoleApp1\Program.cs(1,1,33,2): warning CS0028: '<top-level-statements-entry-point>' has the wrong signature to be an entry point
1>C:\temp\ConsoleApp1\Program.cs(6,1,13,4): error CS1061: 'Task' does not contain a definition for 'GetAwaiter' and no accessible extension method 'GetAwaiter' accepting a first argument of type 'Task' could be found (are you missing a using directive or an assembly reference?)
1>CSC : error CS5001: Program does not contain a static 'Main' method suitable for an entry point
1>C:\temp\ConsoleApp1\Program.cs(6,1,13,3): error CS1061: 'Task<int>' does not contain a definition for 'GetAwaiter' and no accessible extension method 'GetAwaiter' accepting a first argument of type 'Task<int>' could be found (are you missing a using directive or an assembly reference?)
========== Rebuild All: 0 succeeded, 1 failed, 0 skipped ==========

오류 메시지가 "warning CS0028: '<top-level-statements-entry-point>' has the wrong signature to be an entry point"로 시작해 "error CS5001: Program does not contain a static 'Main' method suitable for an entry point"를 포함하고 있지만 실제 오류는 "error CS1061"에서 보여주는 메시지 때문에 발생하는 것입니다.

즉, C# 9.0의 TLS(최상위 문)로 번역된 <Main>$ 메서드로의 변환이 허용되려면 GetAwaiter 메서드가 필요한데,

Task.GetAwaiter Method
; https://docs.microsoft.com/en-us/dotnet/api/system.threading.tasks.task.getawaiter

그 메서드는 .NET 4.5부터 구현되어 있기 때문입니다. (참고로, "error CS5001: Program does not contain a static 'Main' method suitable for an entry point" 오류 메시지는 ".NET Core 콘솔 프로젝트에서 Kestrel 호스팅 방법" 글에서도 발생한 적이 있습니다.)




[이 글에 대해서 여러분들과 의견을 공유하고 싶습니다. 틀리거나 미흡한 부분 또는 의문 사항이 있으시면 언제든 댓글 남겨주십시오.]







[최초 등록일: ]
[최종 수정일: 5/3/2021]

Creative Commons License
이 저작물은 크리에이티브 커먼즈 코리아 저작자표시-비영리-변경금지 2.0 대한민국 라이센스에 따라 이용하실 수 있습니다.
by SeongTae Jeong, mailto:techsharer at outlook.com

비밀번호

댓글 작성자
 




... [151]  152  153  154  155  156  157  158  159  160  161  162  163  164  165  ...
NoWriterDateCnt.TitleFile(s)
1400정성태1/10/201336740Windows: 69. 작업표시줄의 터치 키보드(Touch Keyboard) 없애는 방법 [3]
1399정성태1/9/201331671.NET Framework: 355. 닷넷 환경이 왜 C/C++보다 느릴까요? [8]
1398정성태1/8/201331442오류 유형: 165. 새로 설치한 Visual Studio 2010의 Team Explorer 실행시 비정상 종료가 된다면?
1397정성태1/3/201335035Windows: 68. 윈도우 설치 ISO 이미지를 USB 하드에 적용하는 방법 [2]
1396정성태12/27/201236383사물인터넷: 2. 넷두이노 - 4.2.0 펌웨어 업데이트 방법 [1]파일 다운로드1
1395정성태12/26/201227461.NET Framework: 354. x64 - AspCompat과 STA COM 개체가 성능에 미치는 영향
1394정성태12/25/201228231.NET Framework: 353. x86 - AspCompat과 STA COM 개체가 성능에 미치는 영향
1393정성태12/25/201229525.NET Framework: 352. x64에서 필수로 지정하도록 바뀐 STAThread 특성 [2]
1392정성태12/21/201239297사물인터넷: 1. .NET Micro Framework - 넷두이노 플러스 [7]
1391정성태12/21/201231685.NET Framework: 351. JavaScriptSerializer, DataContractJsonSerializer, Json.NET [3]파일 다운로드1
1390정성태12/20/201230127.NET Framework: 350. String 데이터를 Stream으로 변환하는 방법 [2]
1389정성태12/12/201229061.NET Framework: 349. .NET Thread 인스턴스로부터 COM Apartment 유형 확인하는 방법파일 다운로드1
1388정성태12/12/201229651.NET Framework: 348. .NET x64 응용 프로그램에서 Teb 주소를 구하는 방법파일 다운로드1
1387정성태12/12/201235528VC++: 64. x64 Visual C++에서 TEB 주소 구하는 방법
1386정성태12/12/201235275디버깅 기술: 53. windbg - 덤프 파일로부터 네이티브 DLL을 추출하는 방법 [1]
1385정성태12/12/201231735디버깅 기술: 52. Windbg - The version of SOS does not match the version of CLR you are debugging.
1384정성태12/12/201235439개발 환경 구성: 178. System32 폴더의 64비트 DLL을 32비트 Depends.exe에서 보는 방법
1383정성태12/10/201231778개발 환경 구성: 177. 기업용 메신저를 위한 Office Communicator Server 2007 설치 [1]
1382정성태12/8/201233908개발 환경 구성: 176. WebPagetest 서버 - 설치 및 테스트
1381정성태12/5/201233278.NET Framework: 347. C# - 프로세스(EXE) 수준의 Singleton 개체 생성 [2]파일 다운로드1
1380정성태11/28/201243783.NET Framework: 346. 닷넷 개발자에게 Node.js의 의미 [17]
1379정성태11/26/201237079.NET Framework: 345. C# 부호(+, -)에 대한 비트 변환 [1]
1378정성태11/22/201238079Java: 14. 안드로이드 - Hello World 실습 [7]
1377정성태11/19/201232047.NET Framework: 344. 닷넷 프로파일러 - ICorProfilerInfo::GetILFunctionBody 함수 버그
1376정성태11/15/201236454디버깅 기술: 51. 닷넷 응용 프로그램에서 특정 예외가 발생했을 때 풀 덤프 받는 방법 [6]
1375정성태11/15/201232959디버깅 기술: 50. windbg의 mscordacwks DLL 로드 문제 - 두 번째 이야기
... [151]  152  153  154  155  156  157  158  159  160  161  162  163  164  165  ...