You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

迁移至.NET Core时,app.config中<supportedRuntime>节点的处理方式咨询

Migrating the <startup> Section from .NET Framework's app.config to .NET Core

Great question! When moving from .NET Framework to .NET Core (including .NET 5+), that <startup> block from your app.config is no longer relevant—you can safely delete it entirely. Here's why and what to do instead:

  • Delete the <startup> code completely
    The <supportedRuntime> element was specific to .NET Framework's CLR bootstrapping process, which tells the system which version of the .NET Framework runtime to use. .NET Core uses a different approach to manage runtime versions, so this section serves no purpose here and can be removed without any side effects.

  • Define your target framework in the .csproj file
    Instead of configuring the runtime in app.config, .NET Core uses the project file (.csproj) to specify the target framework. You'll find a <TargetFramework> element (or <TargetFrameworks> for multi-targeting projects) that handles this. For example:

    <!-- Target a single .NET Core version -->
    <TargetFramework>net8.0</TargetFramework>
    

    If you need to maintain compatibility with your original .NET Framework 4.7.1 while migrating, you can multi-target both frameworks:

    <TargetFrameworks>net471;net8.0</TargetFrameworks>
    

    This lets your project build for both .NET Framework 4.7.1 and the .NET Core version of your choice.

  • For other app.config settings
    If your app.config has other sections like <appSettings> or <connectionStrings>, those can be migrated to appsettings.json (the recommended configuration approach for .NET Core) or you can keep using app.config by adding the System.Configuration.ConfigurationManager NuGet package to maintain backward compatibility. But again, the <startup> section is obsolete in .NET Core and should be deleted.

内容的提问来源于stack exchange,提问作者Bizhan

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.13 09:09:38