2017-11-01 14 views
1

ViewModels를 포함하고 MvvmLight를 사용하는 .NET Standard 2.0 라이브러리를 참조하는 WPF 응용 프로그램이 있습니다. GalaSoft.MvvmLight.Messaging.Messenger을 사용하는 ViewModels의 메시지를 수신하는 오류 처리기를 만들었습니다. Visual Studio에서배포 된 WPF ClickOnce 응용 프로그램에서 파일 또는 어셈블리 'System.Runtime'을로드 할 수 없습니다 .Net 표준 라이브러리 012vmv2ight를 참조하는 App

이 앱이 정상적으로 실행,하지만 난 ClickOnce를를 사용하여 응용 프로그램을 게시 할 때 다음 설치하고 실행하려고, 다음과 같은 예외가 발생합니다

FileNotFoundException

이 예외는 다음에서 발생합니다 줄 :

Messenger.Default.Register<Error>(this, ErrorHandler.DisplayError); 

나는 거의 빈 프로젝트에서 실패를 재현 할 수있었습니다. 다음은 직접보고 싶은 경우 프로젝트에 github 저장소에 대한 링크입니다. SystemRuntimeFail Demo

3 일 동안이 문제를 해결하고 모든 것을 시도하는 방법에 대한 정보는 stackoverflow 게시물을 통해 검색 한 후 내 재치가 거의 끝났어. 도와주세요!

+0

당신이이 글을 읽을나요 문제 해결 this repository에 변화를 추진했다? https://stackoverflow.com/questions/42755274/visual-studio-2017-could-not-load-file-or-assembly-system-runtime-version-4 – mm8

+0

예. 불행히도 도움이되지 않았습니다. 나는 주 프로젝트에서 NetStandard.Library에 대한 참조를 이미 가지고 있었다. (SystemRuntimeFail 데모에 추가했다.) 또한 바인딩 리디렉션을 추가하려고 시도했지만 불행하게도 리디렉션해야 할 버전이 무엇인지 알지 못합니다. 또한이를 파악하는 방법을 알지 못합니다. – Katie

답변

1

문제가 발생한 각 어셈블리에 대해 app.config에 바인딩 리디렉션을 추가하여 문제를 해결할 수있었습니다.

<dependentAssembly>을 모두 포함하는 <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> 태그를 포함하는 this answer에 의해 트립되었다. 내가 이것을 시도했을 때, 작동하지 않았다. 내가 진전 된 그 둘러싸인 태그를 제거하려고 시도 할 때까지는 아니었다. 각 어셈블리에 대해 바인딩 리디렉션을 추가하여 예외를 발생시키고 마침내 성공했습니다.

다음은 전체 app.config입니다. 나는이 문제를 해결하기 위해 추가하는 데 필요한 부분은 <runtime> 태그

<?xml version="1.0" encoding="utf-8"?> 
<configuration> 
    <startup> 
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1"/> 
    </startup> 
    <runtime> 
    <dependentAssembly> 
     <assemblyIdentity name="System.Runtime" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> 
     <bindingRedirect oldVersion="0.0.0.0-4.1.2.0" newVersion="4.1.2.0" /> 
    </dependentAssembly> 
    <dependentAssembly> 
     <assemblyIdentity name="System.ObjectModel" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> 
     <bindingRedirect oldVersion="0.0.0.0-4.0.11.0" newVersion="4.0.11.0" /> 
    </dependentAssembly> 
    <dependentAssembly> 
     <assemblyIdentity name="System.Collections" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> 
     <bindingRedirect oldVersion="0.0.0.0-4.0.11.0" newVersion="4.0.11.0" /> 
    </dependentAssembly> 
    <dependentAssembly> 
     <assemblyIdentity name="System.Reflection.Extensions" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> 
     <bindingRedirect oldVersion="0.0.0.0-4.0.11.0" newVersion="4.0.11.0" /> 
    </dependentAssembly> 
    <dependentAssembly> 
     <assemblyIdentity name="System.Reflection" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> 
     <bindingRedirect oldVersion="0.0.0.0-4.1.2.0" newVersion="4.1.2.0" /> 
    </dependentAssembly> 
    <dependentAssembly> 
     <assemblyIdentity name="System.Threading" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> 
     <bindingRedirect oldVersion="0.0.0.0-4.0.11.0" newVersion="4.0.11.0" /> 
    </dependentAssembly> 
    <dependentAssembly> 
     <assemblyIdentity name="System.Linq" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> 
     <bindingRedirect oldVersion="0.0.0.0-4.1.2.0" newVersion="4.1.2.0" /> 
    </dependentAssembly> 
    </runtime> 
</configuration> 

내에서 모든 것을 내가