[英]Exc.: Could not load file or assembly 'Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' or one of its dependencies
[英]Could not load file or assembly 'Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' or one of its dependencies
無法加載文件或程序集“Newtonsoft.Json,版本=12.0.0.0,Culture=neutral,PublicKeyToken=30ad4fe6b2a6aeed”或其依賴項之一。定位的程序集的清單定義與程序集引用不匹配。 我正在嘗試在我的類庫項目中使用 Newtonsoft.Json,但出現此錯誤。 我到處搜索,但我在互聯網上找到的解決方案都沒有對我有用。 有誰有想法嗎 ? .csproj 路徑:
<ItemGroup>
<Reference Include="Microsoft.Crm.Sdk.Proxy">
<HintPath>..\packages\Microsoft.CrmSdk.CoreAssemblies.6.1.1\lib\net40\Microsoft.Crm.Sdk.Proxy.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="microsoft.identitymodel, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.IdentityModel.7.0.0\lib\net35\microsoft.identitymodel.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Xrm.Sdk">
<HintPath>..\packages\Microsoft.CrmSdk.CoreAssemblies.6.1.1\lib\net40\Microsoft.Xrm.Sdk.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="Microsoft.Xrm.Sdk.Workflow">
<HintPath>..\packages\Microsoft.CrmSdk.Workflow.6.1.1\lib\net40\Microsoft.Xrm.Sdk.Workflow.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.12.0.3\lib\net40\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Activities" />
<Reference Include="System.IdentityModel" />
<Reference Include="System.Runtime.Serialization" />
<Reference Include="System.ServiceModel" />
<Reference Include="System.Web.Extensions" />
<Reference Include="System.Xml" />
<Reference Include="System.Xml.Linq" />
</ItemGroup>
我的項目中的 app.config 綁定:
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" culture="neutral" publicKeyToken="30ad4fe6b2a6aeed"/>
<bindingRedirect oldVersion="0.0.0.0-12.0.0.0" newVersion="12.0.0.0"/>
</dependentAssembly>
</assemblyBinding>
</runtime>
我錯過了什么嗎? 我正在使用 .Net Framework 4
謝謝
無論是通過包管理控制台還是通過 NuGet GUI,我都會卸載/重新安裝 Newtonsoft.Json。
在包管理器控制台中執行: Update-Package –reinstall Newtonsoft.Json
(請注意,如果您有多個項目,這將對整個解決方案執行此操作)
您可能需要在刪除 app.config 中 Newtonsoft 的dependentAssembly 部分的同時執行此操作。
也永遠不要低估關閉和重新打開 Visual Studio 的能力。 有時,您可以四處奔波,尋找與 VS 緩存有關的問題的答案。
清理這個爛攤子的可能性很小。 使用其中的一種或幾種:
正如之前的回復中所說的Update-Package –reinstall Newtonsoft.Json
卸載Newtonsoft.Json
及其上所有引用的包 + 手動刪除 csproj 中的所有綁定重定向和引用,然后再次安裝該包。
重新安裝解決方案Update-Package -reinstall
所有包。
使用 .NET Core(最好的)
希望,它會有所幫助。
通過將引用直接鏈接到 .nuget\\packages\\newtonsoft.json\\12.0.1\\lib\\net40\\NewtonSoft.Json.dll 中的包內容解決了這個問題
在包管理器中有一個參考可以確保包在那里。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.