今天遇到了一個比較坑的問題,琢磨了好久。。。
因為需要引用一個第三方的類庫,三方的類庫引用的是Newtonsoft.Json.dll 版本7.0.0而我的項目中引用的是Newtonsoft.Json.dll 版本4.5.0,這樣兩個引用造成了沖突。所有的引用都OK,編譯時提示“ Newtonsoft.Json.Linq”未引用,可是這明明已經引用了。嘗試使用nuget更新,更新到最新版9.0.0,更新成功后可以一成功編譯,但是訪問時又出現這個樣的問題。
最終解決方法,修改web.config,這里只是告訴大家格式,只用添加完整的dependentAssembly內容即可。
<runtime> <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> <dependentAssembly> <assemblyIdentity name="WebGrease" publicKeyToken="31bf3856ad364e35" culture="neutral" /> <bindingRedirect oldVersion="0.0.0.0-1.5.2.14234" newVersion="1.5.2.14234" /> </dependentAssembly> <dependentAssembly> <assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" /> <bindingRedirect oldVersion="0.0.0.0-7.0.0.0" newVersion="7.0.0.0" /> </dependentAssembly> </assemblyBinding> </runtime>