close

這問題還蠻常發生,舊版本的Newtonsoft.Json被預設安裝或者因為其他組建的

相關組件是4.5,以至於安裝新版後,或被其他新安裝的組件時附屬裝了新版,則執行時會出現以下錯誤:

 

 

無法載入檔案或組件 'Newtonsoft.Json, Version=4.5.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' 或其相依性的其中之一。 找到的組件資訊清單定義與組件參考不符。 (發生例外狀況於 HRESULT: 0x80131040)

而在packages.config裡都沒有出現4.5的字眼,相當OOXX!!

解決方法就是要在 web.config 裡面強制設定dependentAssembly

 

 <runtime>
 
 <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
 
 <dependentAssembly>
 
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral"/>
 
 <bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0"/>
 
</dependentAssembly>
 
 </assemblyBinding>
 
 </runtime>
arrow
arrow
    全站熱搜

    baechang 發表在 痞客邦 留言(0) 人氣()