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
정성태

... 76  77  78  79  80  81  [82]  83  84  85  86  87  88  89  90  ...
NoWriterDateCnt.TitleFile(s)
11886정성태5/7/201919173오류 유형: 534. mstest.exe 실행 시 "Visual Studio Enterprise is required to execute the test." 오류 [2]
11885정성태5/7/201916082오류 유형: 533. mstest.exe 실행 시 "File extension specified '.loadtest' is not a valid test extension." 오류 발생
11884정성태5/5/201920921.NET Framework: 828. C# DLL에서 Win32 C/C++처럼 dllexport 함수를 제공하는 방법 - 두 번째 이야기
11883정성태5/3/201926129.NET Framework: 827. C# - 인터넷 시간 서버로부터 받은 시간을 윈도우에 적용하는 방법파일 다운로드1
11882정성태5/2/201922370.NET Framework: 826. (번역글) .NET Internals Cookbook Part 11 - Various C# riddles파일 다운로드1
11881정성태4/28/201922516오류 유형: 532. .NET Core 프로젝트로 마이그레이션 시 "CS0579 Duplicate 'System.Reflection.AssemblyCompanyAttribute' attribute" 오류 발생
11880정성태4/25/201918330오류 유형: 531. 이벤트 로그 오류 - Task Scheduling Error: m->NextScheduledSPRetry 1547, m->NextScheduledEvent 1547
11879정성태4/24/201926739.NET Framework: 825. (번역글) .NET Internals Cookbook Part 10 - Threads, Tasks, asynchronous code and others파일 다운로드2
11878정성태4/22/201922501.NET Framework: 824. (번역글) .NET Internals Cookbook Part 9 - Finalizers, queues, card tables and other GC stuff파일 다운로드1
11877정성태4/22/201922538.NET Framework: 823. (번역글) .NET Internals Cookbook Part 8 - C# gotchas파일 다운로드1
11876정성태4/21/201921632.NET Framework: 822. (번역글) .NET Internals Cookbook Part 7 - Word tearing, locking and others파일 다운로드1
11875정성태4/21/201922589오류 유형: 530. Visual Studo에서 .NET Core 프로젝트를 열 때 "One or more errors occurred." 오류 발생
11874정성태4/20/201922782.NET Framework: 821. (번역글) .NET Internals Cookbook Part 6 - Object internals파일 다운로드1
11873정성태4/19/201921255.NET Framework: 820. (번역글) .NET Internals Cookbook Part 5 - Methods, parameters, modifiers파일 다운로드1
11872정성태4/17/201922107.NET Framework: 819. (번역글) .NET Internals Cookbook Part 4 - Type members파일 다운로드1
11871정성태4/16/201920848.NET Framework: 818. (번역글) .NET Internals Cookbook Part 3 - Initialization tricks [3]파일 다운로드1
11870정성태4/16/201919042.NET Framework: 817. Process.Start로 실행한 콘솔 프로그램의 출력 결과를 얻는 방법파일 다운로드1
11869정성태4/15/201924865.NET Framework: 816. (번역글) .NET Internals Cookbook Part 2 - GC-related things [2]파일 다운로드2
11868정성태4/15/201920851.NET Framework: 815. CER(Constrained Execution Region)이란?파일 다운로드1
11867정성태4/15/201920026.NET Framework: 814. Critical Finalizer와 SafeHandle의 사용 의미파일 다운로드1
11866정성태4/9/201923216Windows: 159. 네트워크 공유 폴더(net use)에 대한 인증 정보는 언제까지 유효할까요?
11865정성태4/9/201918897오류 유형: 529. 제어판 - C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Administrative Tools is not accessible.
11864정성태4/9/201917611오류 유형: 528. '...' could be '0': this does not adhere to the specification for the function '...'
11863정성태4/9/201917501디버깅 기술: 127. windbg - .NET x64 EXE의 EntryPoint
11862정성태4/7/201920117개발 환경 구성: 437. .NET EXE의 ASLR 기능을 끄는 방법
11861정성태4/6/201919523디버깅 기술: 126. windbg - .NET x86 CLR2/CLR4 EXE의 EntryPoint
... 76  77  78  79  80  81  [82]  83  84  85  86  87  88  89  90  ...