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

windbg - 덤프 파일로부터 추출한 DLL 참조 시 "Resolved file has a bad image, no metadata, or is otherwise inaccessible." 빌드 오류

예전에 windbg에서 덤프 파일로부터 .NET DLL을 추출하는 방법을 설명했습니다.

windbg - 풀 덤프 파일로부터 .NET DLL을 추출/저장하는 방법
; https://www.sysnet.pe.kr/2/0/10943

해당 DLL을 그대로 참조하려고 할 때 "Resolved file has a bad image, no metadata, or is otherwise inaccessible."라는 오류가 발생했습니다. 이상하군요... 예전에는 그냥 참조를 했었던 것 같은데 어느 시점부턴가 이것이 바뀐 것 같습니다. 재미있는 것은, 어떤 DLL은 정상적으로 참조가 되었기 때문에 여전히 가능한 규칙이 있을 것 같았습니다.

그래서 테스트를 해봤습니다. ^^

.NET 4.5 EXE에서 AnyCPU 타겟의 .NET 3.5 및 .NET 4.5 DLL을 각각 참조하고 덤프를 뜬 후 DLL을 추출해 새 프로젝트에서 참조했습니다. 결과는 2개 모두 참조 실패가 나왔습니다. (오류 메시지와는 달리 .NET Reflector 등에서의 역어셈블은 잘 됩니다.)

1>------ Rebuild All started: Project: ConsoleApp1, Configuration: Debug Any CPU ------
1>C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\Microsoft.Common.CurrentVersion.targets(2106,5): warning MSB3246: Resolved file has a bad image, no metadata, or is otherwise inaccessible. Could not load file or assembly 'ClassLibrary20.dll' or one of its dependencies. An attempt was made to load a program with an incorrect format.
1>C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\Microsoft.Common.CurrentVersion.targets(2106,5): warning MSB3246: Resolved file has a bad image, no metadata, or is otherwise inaccessible. Could not load file or assembly 'ClassLibrary40.dll' or one of its dependencies. An attempt was made to load a program with an incorrect format.
1>  ConsoleApp1 -> F:\ConsoleApp1\bin\Debug\ConsoleApp1.exe
========== Rebuild All: 1 succeeded, 0 failed, 0 skipped ==========

재미있는 것은, !savemodule이 저장한 2개의 DLL 모두 타겟이 AnyCPU에서 .NET 4.5 EXE가 실행된 64비트에 맞게 x64로 변경되었다는 것입니다. 혹시 이것 때문일까요?

그래서 다시 테스트 프로젝트를 하나 더 추가했습니다. .NET 4.5 EXE가 64비트 프로세스로 실행되었기 때문에 이번에는 아예 .NET 3.5 DLL의 타겟을 AnyCPU에서 x64로 맞추고 빌드한 후 덤프를 떠 다시 과정을 반복했습니다.

오호~~~ 이번에는 ^^ 잘 참조가 됩니다. 그러니까, 현재 windbg의 덤프 파일로부터 추출한 DLL이 원본부터 플랫폼이 지정된 경우에 한해 정상적으로 참조할 수 있는 것입니다. 그리고 추출한 DLL이 원본과 플랫폼이 다른 경우에는, 다음의 글에 따라 처리를 해야만 참조할 수 있습니다.

windbg - 덤프 파일로부터 추출한 DLL을 참조하는 방법
; https://www.sysnet.pe.kr/2/0/11639




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

[연관 글]






[최초 등록일: ]
[최종 수정일: 8/2/2018]

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

비밀번호

댓글 작성자
 




... 46  47  48  49  50  51  52  53  54  55  56  [57]  58  59  60  ...
NoWriterDateCnt.TitleFile(s)
12207정성태4/2/20208951스크립트: 19. Windows PowerShell의 NonInteractive 모드
12206정성태4/2/202011244오류 유형: 613. 파일 잠금이 바로 안 풀린다면? - The process cannot access the file '...' because it is being used by another process.
12205정성태4/2/20208637스크립트: 18. Powershell에서는 cmd.exe의 명령어를 지원하진 않습니다.
12204정성태4/1/20208439스크립트: 17. Powershell 명령어에 ';' (semi-colon) 문자가 포함된 경우
12203정성태3/18/202010475오류 유형: 612. warning: 'C:\ProgramData/Git/config' has a dubious owner: '...'.
12202정성태3/18/202013093개발 환경 구성: 486. .NET Framework 프로젝트를 위한 GitLab CI/CD Runner 구성
12201정성태3/18/202010887오류 유형: 611. git-credential-manager.exe: Using credentials for username "Personal Access Token". [1]
12200정성태3/18/202011327VS.NET IDE: 145. NuGet + Github 라이브러리 디버깅 관련 옵션 3가지 - "Enable Just My Code" / "Enable Source Link support" / "Suppress JIT optimization on module load (Managed only)"
12199정성태3/17/20209179오류 유형: 610. C# - CodeDomProvider 사용 시 Unhandled Exception: System.IO.DirectoryNotFoundException: Could not find a part of the path '...\f2_6uod0.tmp'.
12198정성태3/17/202011919오류 유형: 609. SQL 서버 접속 시 "Cannot open user default database. Login failed."
12197정성태3/17/202011062VS.NET IDE: 144. .NET Core 콘솔 응용 프로그램을 배포(publish) 시 docker image 자동 생성 - 두 번째 이야기 [1]
12196정성태3/17/20208994오류 유형: 608. The ServicedComponent being invoked is not correctly configured (Use regsvcs to re-register).
12195정성태3/16/202010706.NET Framework: 902. C# - 프로세스의 모든 핸들을 열람 - 세 번째 이야기
12194정성태3/16/202013027오류 유형: 607. PostgreSQL - Npgsql.NpgsqlException: sorry, too many clients already
12193정성태3/16/20209705개발 환경 구성: 485. docker - SAP Adaptive Server Enterprise 컨테이너 실행 [1]
12192정성태3/14/202012153개발 환경 구성: 484. docker - Sybase Anywhere 16 컨테이너 실행
12191정성태3/14/202012527개발 환경 구성: 483. docker - OracleXE 컨테이너 실행 [1]
12190정성태3/14/20208645오류 유형: 606. Docker Desktop 업그레이드 시 "The process cannot access the file 'C:\Program Files\Docker\Docker\resources\dockerd.exe' because it is being used by another process."
12189정성태3/13/202013488개발 환경 구성: 482. Facebook OAuth 처리 시 상태 정보 전달 방법과 "유효한 OAuth 리디렉션 URI" 설정 규칙
12188정성태3/13/202015790Windows: 169. 부팅 시점에 실행되는 chkdsk 결과를 확인하는 방법
12187정성태3/12/20208465오류 유형: 605. NtpClient was unable to set a manual peer to use as a time source because of duplicate error on '...'.
12186정성태3/12/20209538오류 유형: 604. The SysVol Permissions for one or more GPOs on this domain controller and not in sync with the permissions for the GPOs on the Baseline domain controller.
12185정성태3/11/202010231오류 유형: 603. The browser service was unable to retrieve a list of servers from the browser master...
12184정성태3/11/202011639오류 유형: 602. Automatic certificate enrollment for local system failed (0x800706ba) The RPC server is unavailable. [3]
12183정성태3/11/202010007오류 유형: 601. Warning: DsGetDcName returned information for \\[...], when we were trying to reach [...].
12182정성태3/11/202011216.NET Framework: 901. C# Windows Forms - Vista/7 이후의 Progress Bar 업데이트가 느린 문제파일 다운로드1
... 46  47  48  49  50  51  52  53  54  55  56  [57]  58  59  60  ...