最近做了C#调用Redis功能,在本地开发时没问题,但是发到了生产就报错,
错误信息:
Could not load file or assembly 'System.Threading.Tasks, Version=1.5.11.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
在网上找了很多方法没有解决,
其中也加了runtime
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Runtime" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-2.6.10.0" newVersion="2.6.10.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Threading.Tasks" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-2.6.10.0" newVersion="2.6.10.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
加了以上节点也不行
然后在服务器上安装了.netframework4.5.2,问题解决了。
去官方下载:NDP452-KB2901907-x86-x64-AllOS-ENU.exe
在将C#应用部署到生产环境时,遇到调用Redis功能报错,错误信息涉及System.Threading.Tasks组件版本不匹配。尝试通过修改配置文件中的assemblyBinding未解决问题。最终解决方案是在服务器上安装.NET Framework 4.5.2,问题得到解决。建议在部署前确保所有依赖项与目标环境兼容。

被折叠的 条评论
为什么被折叠?



