Microsoft MVP성태의 닷넷 이야기
오류 유형: 907. MySqlConnector 사용 시 System.IO.FileLoadException 오류 [링크 복사], [링크+제목 복사],
조회: 7540
글쓴 사람
정성태 (seongtaejeong at gmail.com)
홈페이지
첨부 파일
 

MySqlConnector 사용 시 System.IO.FileLoadException 오류

.NET Framework 환경에서 MySqlConnector의 MySqlConnection.Open 메서드 실행 시 이런 오류가 발생할 수 있습니다.

System.IO.FileLoadException
  HResult=0x80131040
  Message=Could not load file or assembly 'System.Diagnostics.DiagnosticSource, Version=6.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
  Source=MySqlConnector
  StackTrace:
   at MySqlConnector.MySqlConnection.<OpenAsync>d__26.MoveNext()
   at System.Runtime.CompilerServices.AsyncTaskMethodBuilder.Start[TStateMachine](TStateMachine& stateMachine)
   at MySqlConnector.MySqlConnection.OpenAsync(Nullable`1 ioBehavior, CancellationToken cancellationToken)
   at MySqlConnector.MySqlConnection.Open()

물론, 진짜로 System.Diagnostics.DiagnosticSource 어셈블리가 참조돼 있지 않다면 새롭게 설치하면 되는데요,

Install-Package System.Diagnostics.DiagnosticSource -Version 6.0.0.0

기존에 이미 6.0.0.0보다 높은 버전으로 해당 어셈블리가 참조돼 있어도 저 오류가 발생할 것입니다. 그런 경우, 프로젝트 빌드 시 경고를 자세히 보면 이런 식의 메시지가 보일 텐데,

1> Consider app.config remapping of assembly "System.Diagnostics.DiagnosticSource, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51" from Version "6.0.0.0" [] to Version "7.0.0.2" [C:\temp\WebSamples\packages\System.Diagnostics.DiagnosticSource.7.0.2\lib\net462\System.Diagnostics.DiagnosticSource.dll] to solve conflict and get rid of warning.


전에도 이야기했지만,

Consider app.config remapping of assembly "..." from Version "..." [...] to Version "..." [...] to solve conflict and get rid of warning.
; https://www.sysnet.pe.kr/2/0/12027

이런 경우 AutoGenerateBindingRedirects 옵션을 True로 주거나, 아니면 app.config/Web.config 등에 assemblyBinding으로 이렇게 추가시켜 주면 됩니다.

<runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
        <!-- ...[생략]... -->

        <dependentAssembly>
            <assemblyIdentity name="System.Diagnostics.DiagnosticSource" publicKeyToken="cc7b13ffcd2ddd51"/>
            <bindingRedirect oldVersion="0.0.0.0-7.0.0.2" newVersion="7.0.0.2"/>
        </dependentAssembly>

        <!-- ...[생략]... -->
    </assemblyBinding>
</runtime>

참고로, 위와 같은 바인딩 정책에 대해서는 이미 아래의 글에서 자세하게 설명한 적이 있고,

.NET Framework의 Strong-named 어셈블리 바인딩 (1) - app.config을 이용한 바인딩 리디렉션
; https://www.sysnet.pe.kr/2/0/12210

.NET Core/5+가 대세가 된 요즘에는 발생하지 않을 문제이니 가볍게 알고만 지나가도 될 문제입니다. ^^




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







[최초 등록일: ]
[최종 수정일: 6/12/2024]

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

비밀번호

댓글 작성자
 




1  2  3  4  5  6  7  8  9  [10]  11  12  13  14  15  ...
NoWriterDateCnt.TitleFile(s)
13677정성태7/15/20246094오류 유형: 916. MSBuild - CheckEolTargetFramework (warning NETSDK1138)
13676정성태7/14/20246356Linux: 75. gdb에서 glibc의 함수에 Breakpoint 걸기
13675정성태7/13/20247900C/C++: 166. C/C++ - DLL에서 template 함수를 export하는 방법 [1]파일 다운로드1
13674정성태7/13/20247011오류 유형: 915. Unhandled Exception: Microsoft.Diagnostics.NETCore.Client.ServerNotAvailableException: Unable to connect to Process
13673정성태7/11/20247286닷넷: 2275. C# 13 - (1) 신규 이스케이프 시퀀스 '\e'파일 다운로드1
13672정성태7/10/20246622닷넷: 2274. IIS - (프로세스 종료 없는) AppDomain Recycle
13671정성태7/10/20246486오류 유형: 914. Package ca-certificates is not installed.
13669정성태7/9/20246660오류 유형: 913. C# - AOT StaticExecutable 정적 링킹 시 빌드 오류
13668정성태7/8/20246586개발 환경 구성: 716. Hyper-V - Ubuntu 22.04 Generation 2 유형의 VM 설치
13667정성태7/7/20246108닷넷: 2273. C# - 리눅스 환경에서의 Hyper-V Socket 연동 (AF_VSOCK)파일 다운로드1
13666정성태7/7/20246688Linux: 74. C++ - Vsock 예제 (Hyper-V Socket 연동)파일 다운로드1
13665정성태7/6/20246884Linux: 73. Linux 측의 socat을 이용한 Hyper-V 호스트와의 vsock 테스트파일 다운로드1
13663정성태7/5/20246776닷넷: 2272. C# - Hyper-V Socket 통신(AF_HYPERV, AF_VSOCK)의 VMID Wildcards 유형파일 다운로드1
13662정성태7/4/20247114닷넷: 2271. C# - WSL 2 VM의 VM ID를 알아내는 방법 - Host Compute System API파일 다운로드1
13661정성태7/3/20246953Linux: 72. g++ - 다른 버전의 GLIBC로 소스코드 빌드
13660정성태7/3/20246621오류 유형: 912. Visual C++ - Linux 프로젝트 빌드 오류
13659정성태7/1/20247104개발 환경 구성: 715. Windows - WSL 2 환경의 Docker Desktop 네트워크
13658정성태6/28/20247035개발 환경 구성: 714. WSL 2 인스턴스와 호스트 측의 Hyper-V에 운영 중인 VM과 네트워크 연결을 하는 방법 - 두 번째 이야기
13657정성태6/27/20247372닷넷: 2270. C# - Hyper-V Socket 통신(AF_HYPERV, AF_VSOCK)을 위한 EndPoint 사용자 정의
13656정성태6/27/20246921Windows: 264. WSL 2 VM의 swap 파일 위치
13655정성태6/24/20246998닷넷: 2269. C# - Win32 Resource 포맷 해석파일 다운로드1
13654정성태6/24/20247006오류 유형: 911. shutdown - The entered computer name is not valid or remote shutdown is not supported on the target computer.
13653정성태6/22/20247148닷넷: 2268. C# 코드에서 MAKEINTREOURCE 매크로 처리
13652정성태6/21/20248101닷넷: 2267. C# - Linux 환경에서 (Reflection 없이) DLL AssemblyFileVersion 구하는 방법파일 다운로드2
13651정성태6/19/20247467닷넷: 2266. C# - (Reflection 없이) DLL AssemblyFileVersion 구하는 방법파일 다운로드1
13650정성태6/18/20247262개발 환경 구성: 713. "WSL --debug-shell"로 살펴보는 WSL 2 VM의 리눅스 환경
1  2  3  4  5  6  7  8  9  [10]  11  12  13  14  15  ...