.NET Core
2.2 升級 3.1嚴重性 程式碼 說明 專案 檔案 行 隱藏項目狀態
警告 CS0618 'CompatibilityVersion.Version_2_2' 已經過時: 'This CompatibilityVersion value is obsolete. The recommended alternatives are Version_3_0 or later.' TLDE.Frontend.Host C:\Azure\TLDE.Service\TLDE.Frontend.Host\Startup.cs 43 作用中
services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2);
改成
services.AddControllers();
嚴重性 程式碼 說明 專案 檔案 行 隱藏項目狀態
警告 CS0618 'IHostingEnvironment' 已經過時: 'This type is obsolete and will be removed in a future version. The recommended alternative is Microsoft.AspNetCore.Hosting.IWebHostEnvironment.' TLDE.Frontend.Host C:\Azure\TLDE.Service\TLDE.Frontend.Host\Startup.cs 46 作用中
IHostingEnvironment
改成 IWebHostEnvironment
參考 - 從 ASP.NET Core 2.2 遷移至 3.0
移除 Microsoft.AspNetCore.App
與 Microsoft.AspNetCore.Razor.Design
warning MVC1005: Using 'UseMvc' to configure MVC is not supported while using Endpoint Routing. To continue using 'UseMvc', please set 'MvcOptions.EnableEndpointRouting = false' inside 'ConfigureServices'.
app.UseMvc();
改成
app.UseRouting();
app.UseAuthorization();
app.UseEndpoints(endpoints =>
{
endpoints.MapControllers();
});
The CORS protocol does not allow specifying a wildcard (any) origin and credentials at the same time. Configure the CORS policy by listing individual origins if credentials needs to be supported.
刪除程式碼
app.UseCors(
builder => builder
.AllowAnyOrigin()
.AllowAnyMethod()
.AllowAnyHeader()
.AllowCredentials());
System.InvalidOperationException: Synchronous operations are disallowed. Call ReadAsync or set AllowSynchronousIO to true instead.
at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpRequestStream.Read(Byte[] buffer, Int32 offset, Int32 count)
at System.IO.StreamReader.ReadBuffer()
at System.IO.StreamReader.ReadToEnd()
at CArk.Host.DotNetCore.CArkHostDotNetCore.ProcessRequest(HttpContext context, Func`1 next)
at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.Invoke(HttpContext context)
新增程式碼
public void ConfigureServices(IServiceCollection services)
{
services.AddControllers();
services.AddCors(options =>
{
options.AddPolicy("CorsPolicy",
builder => builder
.AllowAnyOrigin()
.AllowAnyMethod()
.AllowAnyHeader());
});
}
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
app.UseDeveloperExceptionPage();
app.UseCors("CorsPolicy");
app.UseCArkSDK(new CArkBaseServicesHost("TLDE", ConfMgr.Instance._config,
new Assembly[] {
typeof(Service_Echo).Assembly, // Health Check
typeof(ContractRequest_Echo).Assembly, // Health Check
typeof(Service_Room_RoomCategoryListALL).Assembly,
typeof(CReq_RoomCategory_ListALL).Assembly
}));
}
參考 - .Net Core 3 preview: Synchronous operations are disallowed
public void ConfigureServices(IServiceCollection services)
{
services.AddControllers();
services.AddCors(options =>
{
options.AddPolicy("CorsPolicy",
builder => builder
.AllowAnyOrigin()
.AllowAnyMethod()
.AllowAnyHeader());
});
}
改成
public void ConfigureServices(IServiceCollection services)
{
services.AddControllers();
services.AddCors(options =>
{
options.AddPolicy("CorsPolicy",
builder => builder
.AllowAnyOrigin()
.AllowAnyMethod()
.AllowAnyHeader());
});
services.Configure<KestrelServerOptions>(options =>
{
options.AllowSynchronousIO = true;
});
services.Configure<IISServerOptions>(options =>
{
options.AllowSynchronousIO = true;
});
}
FolderProfileDebug.pubxml
檔案裡的
<TargetFramework>netcoreapp3.1</TargetFramework>
記得改成 3.1 發布才能正常編譯
還有所有原本是 netstandard2.0
<TargetFramework>netstandard2.0</TargetFramework>
要改成 netstandard2.1
<TargetFramework>netstandard2.1</TargetFramework>
記得是因為 3.0 之後就只支援 netstandard2.1
不然發布時也會編譯不過
.NET Core
工作紀錄
巴哈姆特-唯舞獨尊 Online 介紹網頁
May 4, 2025下載 Cascadia.ttf 安裝 CaskaydiaCove 字型 檔案總管右鍵會有一個安裝選項安裝完後開啟 VSCodeVSCode 也可以點選 在 settings.json 內編輯新增下列設定即可 { "workbench.startupEditor": "newUntitledFile", "editor.fontFamily": "'Cascadia Code', Consolas, 'Courier New', monospace",
Apr 10, 2023VSCode 必裝套件 2021 年補充 Cascadia Code 字型 VSCode 安裝 Cascadia Code Cascadia Code 微軟釋出免費等寬字型,開源更適合程式碼編輯器和終端機 Coding 用字體推薦:Fira Code、JetBrains Mono、Consolas、與 Input Sans JetBrains Mono 更適合閱讀程式碼的等寬字型,內建四種字重斜體可商用
Apr 7, 2023停用硬體加速(省電省記憶體, ==高配請忽視==) Viasfora 大刮號變色、關鍵字變色  Code alignment 自動對齊工具 
Sep 25, 2021or
By clicking below, you agree to our terms of service.
New to HackMD? Sign up