自从.netcore 3.1出来后,大家都想立马升级到最新版本。我也是如此,微软也对.netcore 3.1 的官方组件不断升级,几乎每隔几天就会有部分元包可以升级。每次打开Nuget包管理器,“更新”的tab处总会有个数字暗示着你快点升级!一向有代码洁癖的同学(包括我),都会毫不犹豫的点击“全部升级”。我们总是幻想着使用更高的版本,可以获取更牛的功能和更快的性能。
可惜,梦想是好的,结局却是残酷的。升级后,却发现有很多错误。.netcore 3.1的确在性能方面有极大的提升,各个方面都比.netcore 2.2强多了,但是,其生态还没有完全的发展起来,很多第3方组件依旧还是netcore2.2的版本甚至更低。这个时候最让人头疼的就是包的版本问题,比如如下错误:
MuXue.Zyiz.Net.WebAPI/MuXue.Zyiz.Net.WebAPI.csproj : error NU1605: Detected package downgrade: System.Threading.ThreadPool from 4.3.0 to 4.0.10. Reference the package directly from the project to select a different version.
error NU1605: Detected package downgrade的中文意思是“错误NU1605:检测到包降级 ”。大家都知道,元包里还包含很多子的组件,多个元包之间引用的子组件版本不一致,就会造成这个错误。这种情况在.netcore 3.1目前的情况下经常出现。
根据 官方教程 的知道方案得出解决方案如下:
强制将版本不一致的包升级到统一的版本,(比如我们这里的System.Threading.ThreadPool)
双击MuXue.Zyiz.Net.WebAPI.csproj项目,
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
|
< ItemGroup >
< PackageReference Include = "AutoMapper" Version = "9.0.0" />
< PackageReference Include = "AutoMapper.Extensions.Microsoft.DependencyInjection" Version = "7.0.0" />
< PackageReference Include = "Consul" Version = "0.7.2.6" />
< PackageReference Include = "FluentValidation.AspNetCore" Version = "8.6.1" />
< PackageReference Include = "Microsoft.AspNetCore.Authentication.JwtBearer" Version = "3.1.1" />
< PackageReference Include = "Microsoft.EntityFrameworkCore" Version = "3.1.1" />
< PackageReference Include = "Microsoft.EntityFrameworkCore.SqlServer" Version = "3.1.1" />
< PackageReference Include = "Microsoft.VisualStudio.Web.CodeGeneration.Design" Version = "3.1.1" />
< PackageReference Include = "NLog.Web.AspNetCore" Version = "4.9.0" />
< PackageReference Include = "SkyAPM.Agent.AspNetCore" Version = "0.9.0" />
< PackageReference Include = "Swashbuckle.AspNetCore" Version = "5.0.0" />
< PackageReference Include = "System.Text.Json" Version = "4.7.0" />
< PackageReference Include = "System.Net.NameResolution" Version = "4.3.0" />
< PackageReference Include = "System.Threading.ThreadPool" Version = "4.3.0" />
</ ItemGroup >
|
看到这行代码:
1
|
< PackageReference Include = "System.Threading.ThreadPool" Version = "4.3.0" />
|
将这个组件统一指定为4.3.0版本,问题就解决了。
到此这篇关于asp.net core3.1 引用的元包dll版本兼容性问题解决方案的文章就介绍到这了,更多相关asp.net core dll兼容性 内容请搜索服务器之家以前的文章或继续浏览下面的相关文章希望大家以后多多支持服务器之家!
原文链接:https://www.cnblogs.com/puzi0315/p/12556138.html