錯誤一、
Cannot find compilation library location for package 'System.Security.Cryptography.Pkcs'
修復方法: 將以下配置設定新增到您的 YX.OAM.Web.Mvc.csproj 檔案中。
<GenerateRuntimeConfigDevFile>true</GenerateRuntimeConfigDevFile>
錯誤二、
使用多上下文,升級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<Startup>();
})
.UseCastleWindsor(IocManager.Instance.IocContainer);
}
}
Startup
ConfigureServices方法的返回值修改為void最後一行的return xxx修改為:
// Configure Abp and Dependency Injection services.AddAbpWithoutCreatingServiceProvider<SCMWebMvcModule>(options =>
options.IocManager.IocContainer.AddFacility<LoggingFacility>(
f => f.UseAbpLog4Net().WithConfig(_env.IsDevelopment()
? "log4net.config"
: "log4net.Production.config"
)
));
需要新增log4net.Production.config
<?xml version="1.0" encoding="utf-8"?>
<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>