Autofac과 많은 동적 어셈블리 로딩을 사용하는 상황 에서이 오류가 발생했습니다.
Autofac 해결 작업을 수행하는 동안 런타임에서 어셈블리 중 하나를로드하지 못했습니다. 오류 메시지에이 (가) 불만을 표시했습니다 Method 'MyMethod' in type 'MyType' from assembly 'ImplementationAssembly' does not have an implementation. Windows Server 2012 R2 VM에서 실행할 때 증상이 발생했지만 Windows 10 또는 Windows Server 2016 VM 에서는 발생 하지 않았습니다 .
ImplementationAssemblySystem.Collections.Immutable1.1.37을 참조 IMyInterface<T1,T2>하고 별도 의 인터페이스로 정의 된 인터페이스 구현이 포함 되어 DefinitionAssembly있습니다. DefinitionAssembly참조System.Collections.Immutable 1.1.36.
IMyInterface<T1,T2>"구현되지 않은" 메소드 는 type의 매개 변수 IImmutableDictionary<TKey, TRow>를가집니다.System.Collections.Immutable 집니다.
System.Collections.Immutable프로그램 디렉토리에있는 실제 사본 은 버전 1.1.37입니다. 내 Windows Server 2012 R2 VM에서 GAC에는 System.Collections.Immutable1.1.36 의 복사본이 포함되었습니다. Windows 10 및 Windows Server 2016에서 GAC에는System.Collections.Immutable 1.1.37 되었습니다. GAC에 이전 버전의 DLL이 포함 된 경우에만로드 오류가 발생했습니다.
따라서 어셈블리로드 실패의 근본 원인은에 대한 참조가 일치하지 않았기 때문입니다 System.Collections.Immutable. 인터페이스 정의와 구현은 동일한 모양의 메소드 서명을 가지고 있지만 실제로는 다른 버전의System.Collections.Immutable 했습니다. 따라서 런타임은 구현 클래스가 인터페이스 정의와 일치하는 것으로 간주하지 않았습니다.
내 응용 프로그램 구성 파일에 다음 바인딩 리디렉션을 추가하면 문제가 해결되었습니다.
<dependentAssembly>
<assemblyIdentity name="System.Collections.Immutable" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-1.1.37.0" newVersion="1.1.37.0" />
</dependentAssembly>