库试图加载错误版本的程序集
Library trying to load wrong version of assembly
我有一个使用库“RethinkDb.Driver”的 .NET Standard 项目,但是当我启动我的项目时出现以下错误
Could not load file or assembly 'Newtonsoft.Json, Version=10.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' or one of its dependencies
但是,我的项目已经使用 Newtonsoft.Json 12.0.3。
但是,我无法返回到版本 10.0.0,因为我还在使用另一个需要最新版本的库。
我检查了我的 .csproj,PackageReference 在这里,指向版本 12.0.3
我也已经尝试过清理 NuGet 缓存之类的操作,但没有解决任何问题。
你必须使用 assembly redirect
.
你必须把它放在你的配置文件中。
在库和可执行项目中它将是 app.config
,如果是 Web 项目则将是 web.config
这是 dotnet 的指令,用于解决对 newVersion
的依赖
<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.3.0" newVersion="12.0.3.0"/>
</dependentAssembly>
</assemblyBinding>
</runtime>
我有一个使用库“RethinkDb.Driver”的 .NET Standard 项目,但是当我启动我的项目时出现以下错误
Could not load file or assembly 'Newtonsoft.Json, Version=10.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' or one of its dependencies
但是,我的项目已经使用 Newtonsoft.Json 12.0.3。
但是,我无法返回到版本 10.0.0,因为我还在使用另一个需要最新版本的库。
我检查了我的 .csproj,PackageReference 在这里,指向版本 12.0.3
我也已经尝试过清理 NuGet 缓存之类的操作,但没有解决任何问题。
你必须使用 assembly redirect
.
你必须把它放在你的配置文件中。
在库和可执行项目中它将是 app.config
,如果是 Web 项目则将是 web.config
这是 dotnet 的指令,用于解决对 newVersion
<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.3.0" newVersion="12.0.3.0"/>
</dependentAssembly>
</assemblyBinding>
</runtime>