1. 程式人生 > >無法加載文件或程序集“Newtonsoft.Json”或它的某一個依賴項

無法加載文件或程序集“Newtonsoft.Json”或它的某一個依賴項

schema binding spa direct rec 添加 -c 做了 類庫

未能加載文件或程序集“Newtonsoft.Json”或它的某一個依賴項。找到的程序集清單定義與程序集引用不匹配。 (異常來自 HRESULT:0x80131040)。

有時候我們創建了一個類庫,我們項目又引用了這個類庫,需要我們把Newtonsoft.Json統一化。

對每個引用Newtonsoft.Json的項目做下面的處理:

①刪除bin下面的Newtonsoft.Json.dll

②重新nuget引用Newtonsoft.Json到一個版本(看實際情況,一般是最新)

③添加我們的依賴,然後重新生成

 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-12.0.0.0" newVersion="4.5.0.0" /> <!-- newVersion 一般都是你在nuget種引用的版本的 --> </dependentAssembly> </assemblyBinding> </runtime> </configuration>

特殊情況:

如果你這樣做了還是報錯,列如:

"未能加載文件或程序集“Newtonsoft.Json, Version=4.5.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed”或它的某一個依賴項。找到的程序集清單定義與程序集引用不匹配。 (異常來自 HRESULT:0x80131040)"


執行上面的步驟,把Newtonsoft.Json引用到報錯的版本

無法加載文件或程序集“Newtonsoft.Json”或它的某一個依賴項