• abp9 .net8 升级错误记录


    错误一、

    Cannot find compilation library location for package 'System.Security.Cryptography.Pkcs'

    修复方法: 将以下配置设置添加到您的 YX.OAM.Web.Mvc.csproj 文件中。

    <GenerateRuntimeConfigDevFile>trueGenerateRuntimeConfigDevFile>
    

    错误二、

    使用多上下文,升级mysql Nuget包为8.0.1后,有时会导致无法访问另一个数据库的数据出现

    Access denied for user 'root'@'10.244.4.1' (using password: NO)
    通过查找资料需要更改链接字符串为

     "Default": "server=localhost;user=root;password=1234;database=ef";
    

    错误三、

    Token获取接口 http://localhost:5000/api/TokenAuth/Authenticate

    报错: TIDX10720: Unable to create KeyedHashAlgorithm for algorithm 'HS256', the key size must be greater than: '256' bits, key has '176' bits. (Parameter 'keyBytes')
    https://github.com/dotnet/aspnetcore/issues/49455
    之前的密钥位数不够,密钥必需具有'256'位

    "Authentication": {
      "JwtBearer": {
        "IsEnabled": "true",
        "SecurityKey": "XXXXX_o/YrU/xV2QRD4zLKMr0wNOvYARep4oF3ie+GPi5et6U=",//这里
        "Issuer": "XXXXX",
        "Audience": "XXXXX"
      },
      "Token": {
        "ExpiredTime": 30
      },
      "FunctionSwitch": {
        "FollowEnabled": true
      }
    },
    

    错误四、

    运行项目时报错

    2024-03-04 13:47:45,760 || FATAL || Abp.AbpBootstrapper || MySqlConnector.MySqlException (0x80004005): SSL Authentication Error
    ---> System.Security.Authentication.AuthenticationException: Cannot determine the frame size or a corrupted frame was received.

    数据库来你姐字符串要增加 sslmode=None;

     "Default": "server=localhost;user=root;password=1234;sslmode=None;database=ef";
    

    错误五、

    因为解决方案中使用了盛派的包,需要将Senparc.Weixin.MP 到最新---16.20.5
    在Startup.cs中需要修改

    // 启动 CO2NET 全局注册,必须!
      app.UseSenparcGlobal(env, senparcSetting.Value, globalRegister => { })
          .UseSenparcWeixin(senparcWeixinSetting.Value, weixinRegister =>
          {
              weixinRegister.RegisterMpAccount(senparcWeixinSetting.Value, SenparcWeixinOptions.Name);
              weixinRegister.RegisterTraceLog(ConfigTraceLog);
          });
    
    using Register = Senparc.CO2NET.Register;
    // 启动 CO2NET 全局注册,必须!
    var registerService = Register.UseSenparcGlobal(senparcSetting.Value, globalRegister => { })
         .UseSenparcWeixin(senparcWeixinSetting.Value, (weixinRegister, weixinSetting) =>
         {
             weixinRegister.RegisterMpAccount(senparcWeixinSetting.Value, SenparcWeixinOptions.Name);
             weixinRegister.RegisterTraceLog(ConfigTraceLog);
         });
    

    错误六、

    之前的项目时.net Core 3.1 数据库的一个类

    public virtual byte[] RowVersion { get; set; }
    

    Pomelo.EntityFrameworkCore.MySql version: 8.0.1
    错误: in 8.0.1 Is Timestamp byte[] no longer supported
    需要将其升级为8.0.0 或者8.0.2

    错误七、

    [MaxLength(2048)]
    public virtual string Remarks{ get; set; }
    

    报错: Data too long for column 'Remarks' at row 1
    通过测试查看所有实体, 里面有约束MaxLength大于2000的, 全部删除掉即可

    错误八、

    .net8中, 使用了新的Host.CreateDefaultBuilder(args)创建服务, 因此, 需要对:Program 和Startup 进行修改:

    Program

     using Abp.AspNetCore.Dependency;  
    using Abp.Dependency;  
    using Microsoft.AspNetCore.Hosting;  
    using Microsoft.Extensions.Hosting;  
    namespace XXXX.XXX.Web.Startup  
    {  
        public class Program
        {
            public static void Main(string[] args)
            {
                CreateHostBuilder(args).Build().Run();
            }
    
            internal static IHostBuilder CreateHostBuilder(string[] args) =>
            Host.CreateDefaultBuilder(args)
                .ConfigureWebHostDefaults(webBuilder =>
                {
                    webBuilder.UseStartup();
                })
                .UseCastleWindsor(IocManager.Instance.IocContainer);
        }
    }
    

    Startup
    ConfigureServices方法的返回值修改为void最后一行的return xxx修改为:

    // Configure Abp and Dependency Injection  services.AddAbpWithoutCreatingServiceProvider(options => 
          options.IocManager.IocContainer.AddFacility(  
          f => f.UseAbpLog4Net().WithConfig(_env.IsDevelopment()  
          ? "log4net.config"  
          : "log4net.Production.config"  
          )  
    ));
    

    需要新增log4net.Production.config

     
    
    <log4net>
        <appender name="RollingFileAppender" type="log4net.Appender.RollingFileAppender">
            <file value="App_Data/Logs/Logs.log" />
            <appendToFile value="true" />
            <rollingStyle value="Size" />
            <maxSizeRollBackups value="10" />
            <maximumFileSize value="10000KB" />
            <staticLogFileName value="true" />
            <layout type="log4net.Layout.PatternLayout">
                <conversionPattern value="%date || %5level || %logger || %message || %exception ||end %newline" />
            layout>
        appender>
        <root>
            <appender-ref ref="RollingFileAppender" />
            <level value="DEBUG" />
        root>
        <logger name="NHibernate">
            <level value="WARN" />
        logger>
    log4net>
    
  • 相关阅读:
    加密货币恐怖融资惊动国会!而链上分析公司看不下去了,紧急辟谣?
    智慧公厕厂家,揭秘公厕升级的实际应用功能
    每日一题|2022-10-28|907. 子数组的最小值之和|今天不想学,后面补上
    阈值回归模型(Threshold Regression Model)及R实现
    [RTOS 学习记录] 工程管理工具make及makefile
    ShowMeBug入驻腾讯会议,开启专业级技术面试时代
    【spring Cloud】为啥最后报空指针了?Eureka注册Movie对象不成功?
    【云原生 | Kubernetes 系列】--Gitops持续交付 实现从代码克隆到应用部署
    FS4064 SOP8 两节8.4V线性锂电池充电IC
    python LeetCode 刷题记录 66
  • 原文地址:https://www.cnblogs.com/moonstars/p/18090546