Microsoft MVP성태의 닷넷 이야기
글쓴 사람
정성태 (techsharer at outlook.com)
홈페이지
첨부 파일
 
(연관된 글이 2개 있습니다.)

Visual Studio에서 ASP.NET Core 실행할 때 dotnet.exe 프로세스의 -532462766 오류 발생

.NET Core 런타임을 x64 버전만 설치한 경우를 예로 들어 들 텐데요. Visual Studio 2017을 실행해 ASP.NET Core 1.1 프로젝트를 생성하고 "Platform target"을 "x86"으로 준 경우, 실행해 보면 "Output" 창에 다음과 같은 오류 메시지를 볼 수 있습니다.

'dotnet.exe' (CoreCLR: DefaultDomain): Loaded 'C:\Program Files\dotnet\shared\Microsoft.NETCore.App\1.1.2\System.Private.CoreLib.ni.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
The program '[30520] dotnet.exe: Program Trace' has exited with code 0 (0x0).
The program '[30520] dotnet.exe' has exited with code -532462766 (0xe0434352).
The program '[12696] iisexpress.exe: Program Trace' has exited with code 0 (0x0).
The program '[12696] iisexpress.exe' has exited with code 0 (0x0).

오류 메시지 창을 자세히 보면 그 원인을 알 수 있습니다. x86으로 지정했는데도 "C:\Program Files\dotnet" 경로로 실행되었다는 것은 x64 용 dotnet.exe가 호출되었다는 것을 의미합니다. 실제로 명령행을 통해 직접 실행해 봐도 오류 결과가 같다는 것을 알 수 있습니다.

C:\test\WebApplication1\WebApplication1\bin\Debug\netcoreapp1.1>dotnet exec WebApplication1.dll

Unhandled Exception: System.BadImageFormatException: Could not load file or assembly 'WebApplication1.dll'. An attempt was made to load a program with an incorrect format.

C:\test\WebApplication1\WebApplication1\bin\Debug\netcoreapp1.1>echo %ERRORLEVEL%
-532462766

따라서 이런 경우에는 해당 PC에 x86 .NET Core 런타임이 있는지 확인해 봐야 합니다. 즉, "C:\Program Files (x86)\dotnet\" 경로가 있는지 보고, 없다면 다음의 링크에서 다운로드해 설치하는 것으로 해결할 수 있습니다.

Download .NET Core
; https://www.microsoft.com/net/download/core

하지만 다운로드했어도 빌드 오류가 계속 발생할 수 있습니다. 왜냐하면 환경 변수 PATH에 지정된 경로의 우선순위 문제 때문입니다. 만약 다음과 같은 순으로 경로가 지정되어 있다면,

C:\Program Files\dotnet\
C:\Program Files (x86)\dotnet\

Visual Studio는 x64 버전의 dotnet.exe를 먼저 찾아 로드하기 때문에 오류가 발생합니다. 따라서, x86 버전의 환경 변수를 먼저 오게 수정한 후 (적용을 위해) Visual Studio를 재시작하면 x86 플랫폼으로 설정한 프로젝트가 잘 동작하게 됩니다.

물론, 반대의 상황도 마찬가지입니다. 환경 변수 PATH에 x86 dotnet.exe가 먼저 검색이 되는 상황에서 .NET Core 응용 프로그램의 플랫폼을 x64로 지정해 놓으면 역시 동일한 오류가 발생합니다.

마지막으로, 위와 같은 환경 변수의 영향으로 인해 AnyCPU로 지정한 .NET Core 응용 프로그램이 무조건 x86 dotnet.exe에서만 실행될 수 있습니다.




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

[연관 글]






[최초 등록일: ]
[최종 수정일: 7/10/2017]

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

비밀번호

댓글 작성자
 



2018-06-11 02시50분
이 글의 문제는 Directory.Build.targets 파일을 만들어 두는 것으로 해결할 수 있습니다.

.NET Core 프로젝트를 Visual Studio에서 실행 시 System.BadImageFormatException 발생하는 경우
; http://www.sysnet.pe.kr/2/0/11545
정성태

... 106  107  108  109  110  111  112  113  [114]  115  116  117  118  119  120  ...
NoWriterDateCnt.TitleFile(s)
11105정성태11/8/201620963.NET Framework: 622. PeerFinder Wi-Fi Direct 통신 시 Read/Write/Dispose 문제
11104정성태11/8/201619862개발 환경 구성: 305. PeerFinder로 Wi-Fi Direct 연결 시 방화벽 문제
11103정성태11/8/201620371오류 유형: 370. PeerFinder.ConnectAsync의 결과 값인 Task.Result를 호출할 때 System.AggregateException 예외 발생
11102정성태11/8/201620393오류 유형: 369. PeerFinder.FindAllPeersAsync 호출 시 System.UnauthorizedAccessException 예외 발생
11101정성태11/8/201622607.NET Framework: 621. 닷넷 프로파일러의 오류 코드 - 0x80131363
11100정성태11/7/201630203개발 환경 구성: 304. Wi-Fi Direct 지원 여부 확인 방법 [1]
11099정성태11/7/201632051.NET Framework: 620. C#에서 C/C++ 함수로 콜백 함수를 전달하는 예제 코드파일 다운로드1
11098정성태11/7/201621300오류 유형: 368. 빌드 이벤트에서 robocopy 사용 시 $(TargetDir) 매크로를 지정하는 경우 오류 발생
11097정성태11/7/201624328오류 유형: 367. go install: no install location for directory [...경로...] outside GOPATH
11096정성태11/6/201627805디버깅 기술: 83. PDB 파일을 수동으로 다운로드하는 방법
11095정성태11/6/201624426.NET Framework: 619. C# - Cognitive Services 중의 하나인 Face API를 사용해 얼굴 인식 및 흐림(blur) 효과 적용 [1]파일 다운로드1
11094정성태11/5/201626132VC++: 105. Visual Studio 2013/2015 - Ceemple OpenCV 확장을 이용한 웹캠 영상 출력
11093정성태11/4/201625985웹: 34. Edge 브라우저도 지원하는 클립보드 복사를 위한 자바스크립트 코드
11092정성태11/3/201633103.NET Framework: 618. C# - NAudio를 이용한 MP3 파일 재생 [5]파일 다운로드1
11091정성태11/3/201626951VC++: 104. std::call_once를 이용해 thread-safe한 Singleton 객체 생성파일 다운로드1
11090정성태11/1/201628464VC++: 103. C++ CreateTimerQueue, CreateTimerQueueTimer 예제 코드 [9]파일 다운로드1
11089정성태11/1/201628244디버깅 기술: 82. Windows 10을 위한 Symbol(PDB) 파일 내려받는 방법 [2]
11088정성태11/1/201631465.NET Framework: 617. C# - AForge.NET을 이용한 MP4 동영상 파일 재생 [7]파일 다운로드1
11087정성태11/1/201625748.NET Framework: 616. AForge.Video.FFMPEG를 최신 버전의 ffmpeg 파일로 의존성을 변경하는 방법파일 다운로드1
11086정성태11/1/201620094오류 유형: 366. The Microsoft Passport Container service terminated with the following error: General access denied error
11085정성태10/27/201634877.NET Framework: 615. C# - AForge.NET을 이용한 웹캠 영상 출력 [2]파일 다운로드1
11084정성태10/26/201622834오류 유형: 365. The User Profile Service service failed to the sign-in.
11083정성태10/26/201629068Windows: 131. 윈도우 10에서 사라진 "Adapters and Bindings" 네트워크 우선 순위 조정 기능 [1]
11082정성태10/26/201631335.NET Framework: 614. C# - DateTime.Ticks의 정밀도 [4]파일 다운로드1
11081정성태10/26/201621475오류 유형: 364. You need to fix your Microsoft Account for apps on your other devices to be able to launch apps and continue experiences on this device.
11080정성태10/24/201624875Windows: 130. Windows Server 2016 Nano 서버 설치 방법
... 106  107  108  109  110  111  112  113  [114]  115  116  117  118  119  120  ...