2016-06-14 3 views
0

C#プロジェクトでHttpClient.GetAsync()を使用し始めています。このメソッドが呼ばれるたびに、それは爆発し、Newtonsoft.Jsonを見つけることができません。HttpClient.GetAsync()はFileLoadExceptionをスローし、Newtonsoft.JsonNETを見つけることができません

このメソッドを取得するには、Microsoft.AspNet.WebApi.Clientナゲットパッケージバージョン5.2.3をインストールしました。これは、Newtonsoft.Json、v 6以上の依存関係を示しています。バージョン8.0.3がインストールされています。

私は間違っていますか?ナゲットパッケージはそれ自身の依存関係を管理する必要がありますか?そしてなぜシステムDLLのためのナゲット?次のように完全な誤りがある...

System.IO.FileLoadException was unhandled by user code 
    FileName=Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed 
    FusionLog=WRN: Assembly binding logging is turned OFF. 
To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1. 
Note: There is some performance penalty associated with assembly bind failure logging. 
To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog]. 

    HResult=-2146234304 
    Message=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) 
    Source=System.Net.Http.Formatting 
    StackTrace: 
     at System.Net.Http.Formatting.BaseJsonMediaTypeFormatter..ctor() 
     at System.Net.Http.Formatting.JsonMediaTypeFormatter..ctor() 
     at System.Net.Http.Formatting.MediaTypeFormatterCollection.CreateDefaultFormatters() 
     at System.Net.Http.HttpContentExtensions.get_DefaultMediaTypeFormatterCollection() 
     at System.Net.Http.HttpContentExtensions.ReadAsAsync[T](HttpContent content) 
     at Dimo.Notilus.Interfaces.Expense.HubHacienda.<>c__DisplayClass0_0.<GetFromHub>b__0(Task`1 task) in C:\NotilusTNE\Sources\NotilusWeb\Agile\Dev\NotilusWeb\Dimo.Notilus.Interfaces\Expense\HubHacienda.cs:line 22 
     at System.Threading.Tasks.Task.Execute() 
    InnerException: 
+0

をリダイレクト結合アセンブリを追加しよう – Rangesh

答えて

1

は、アップデート・パッケージ-reinstall -Project YourProjectName、パッケージマネージャコンソールでこれを試してみてくださいあなたのアプリ/ web.configファイルに

<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-8.0.0.0" newVersion="8.0.0.0" /> 
     </dependentAssembly> 
    </assemblyBinding> 
</runtime> 
</configuration> 
+0

それは便利なトリックありがとうございます。 – bbsimonbb

+1

asp net coreにSystem.Diagnostics.DiagnosticSourceの同様の例外がありました。 /app.configにアセンブリのバインディングを追加すると、それが解決されました。 – Magu

関連する問題