2017-10-13 7 views
0

내가 디버깅 할 때 나는 아래 예외 상황에 직면했다.파일 또는 어셈블리 'Newtonsoft.Json'또는 해당 종속성 중 하나를로드 할 수 없습니다?

var connection = new HubConnection("http://localhost:8080/"); 

Exception: 
Could not load file or assembly 'Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040) 

내 serverHub.exe (콘솔 앱) 및 winforms 인 클라이언트 모듈을 덤프 한 폴더를 만들었습니다. 클라이언트 측에서 위에서 언급 한 단계를 호출 할 때 예외가 발생했습니다.

먼저 Newtonsoft.Json 버전을 6.0.0.0으로 설치했고 나중에 버전 9.0.1으로 업데이트했습니다. 이제 내가 만든 공통 폴더에 dll의 (Microsoft.Asp.Net.Client.dll, Newtonsoft.Json.dll along with other dll's required)을 복사했습니다. 이것은 내가 예외에 직면했을 때입니다.

내 프로젝트의 참조 (Newtonsoft.Json.dll, Microsoft.Asp.Net.Client.dll)은 "패키지"위치에서 복사 된 dll을 덤프 한 곳에서 새로 만든 폴더를 참조합니다.

다시 이러한 참조를 제거하고 패키지 관리자 (Microsoft.Asp.Net.Client.dll- 버전 : 2.2.1 & Newtonsoft.Json.dll-9.0.1)에서 Nuget 패키지를 다운로드했습니다. 및 참조는 이제 package 위치에서 참조됩니다. 이제 응용 프로그램을 만들려고했지만 이제는 제대로 작동합니다.

의 App.config (고객의) :

<?xml version="1.0" encoding="utf-8"?> 
<configuration> 
    <runtime> 
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> 
     <dependentAssembly> 
     <assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" /> 
     <bindingRedirect oldVersion="0.0.0.0-9.0.0.0" newVersion="9.0.0.0" /> 
     </dependentAssembly> 

    </assemblyBinding> 
    </runtime> 
</configuration> 

의 App.config (서버) :

<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> 
    <dependentAssembly> 
    <assemblyIdentity name="Microsoft.Owin" publicKeyToken="31bf3856ad364e35" culture="neutral" /> 
    <bindingRedirect oldVersion="0.0.0.0-3.1.0.0" newVersion="3.1.0.0" /> 
    </dependentAssembly> 
    <dependentAssembly> 
    <assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" /> 
    <bindingRedirect oldVersion="0.0.0.0-9.0.0.0" newVersion="9.0.0.0" /> 
    </dependentAssembly> 
</assemblyBinding> 

내가 복사합니다 다른 위치를 참조 시작하면 설치된 모든 DLL의 솔루션 디렉토리 아래의 기본 "패키지"위치보다는 위의 예외에 직면하고 있습니다. 우리는 dll이 기본 "패키지"위치가 아닌 다른 위치에서 참조하도록 할 수 있습니까? 그렇다면 내가 잘못하고있는 곳에서 도움을주십시오.

아무도 도와 줄 수 있습니까?

+0

이해가 안됩니다. 작동하지 않지만 왜 작동하지 않는지 알고 싶습니까? –

+0

@ user3739842, 내 질문을 편집했습니다. 명확하지 않은 것에 대해 유감스럽게 생각합니다. 나는 왜 내가 "패키지"라는 기본 위치가 아닌 다른 위치에서 dll을 참조하기 시작했을 때 예외가 발생하는지 알고 싶다. – Siva

답변

0

I는이 도구에 의해 확인하려고 도움이되지 않는 경우 < bindingRedirect oldVersion에 = "0.0.0.0-9.0.1.0"NEWVERSION = "9.0.1.0"/ >

을 재 바인딩을 변경하려고 할 것이다 실제 놓친 것을 확인하기 위해 실행 파일을 실행하는 새로운 위치 : https://stackoverflow.com/a/44251000/2819746