C# HTTP错误500.30-本地主机.net core 3.1.1 API C上的ANCM进程内启动失败#

C# HTTP错误500.30-本地主机.net core 3.1.1 API C上的ANCM进程内启动失败#,c#,api,.net-core,C#,Api,.net Core,Windows错误日志: 未能加载coreclr。异常消息:CLR工作线程已退出 过早地 详情: 具有物理根的应用程序“EnterpriseReportsAPI” “…\Repos\InternalReportsAPI\EnterpriseReportsAPI”加载失败 coreclr。异常消息:CLR工作线程过早退出 进程Id:10688。文件版本:13.1.19350.1。描述:IIS ASP.NET核心模块V2请求处理程序。承诺: e276c8174b8bfdeb70efceafa81c7

Windows错误日志:

未能加载coreclr。异常消息:CLR工作线程已退出 过早地

详情:

具有物理根的应用程序“EnterpriseReportsAPI” “…\Repos\InternalReportsAPI\EnterpriseReportsAPI”加载失败 coreclr。异常消息:CLR工作线程过早退出
进程Id:10688。文件版本:13.1.19350.1。描述:IIS ASP.NET核心模块V2请求处理程序。承诺: e276c8174b8bfdeb70efceafa81c75f8badbc8db

在我尝试通过将静态connectionstring助手更改为注入的服务来进一步进行依赖注入之前,每件事情都或多或少运行良好

public class Connections : IConnections
    {
        private readonly ISecurityServiceHelper _securityServiceHelper;

        public Connections(ISecurityServiceHelper securityServiceHelper)
        {
            _securityServiceHelper = securityServiceHelper;
        }
        public string GetSqlConnectionString(string[] creds)
        {
            return _securityServiceHelper.GetSqlConnectionStringAsync(creds).Result;
        }
    }
然后在startup.cs中,我将其更改为:

public Startup(IConfiguration configuration, IConnections connections)
        {
            Configuration = configuration;
            Connections = connections;
        }

        private readonly IConfiguration Configuration;
        private readonly IConnections Connections;
然后在以下内容中利用这些属性:

string[] creds =
            {
                        Configuration.GetSection("ApplicationCreds").GetSection("appId").Value,
                        Configuration.GetSection("ApplicationCreds").GetSection("appToken").Value,
                        Configuration.GetSection("ConnectionString").GetSection("connectionString").Value
            };
            services.AddDbContext<InternalReportsContext>(options =>
                options.UseSqlServer(Connections.GetSqlConnectionString(creds)));
string[]creds=
{
Configuration.GetSection(“应用程序代码”).GetSection(“应用程序ID”).Value,
Configuration.GetSection(“应用程序代码”).GetSection(“appToken”).Value,
Configuration.GetSection(“ConnectionString”).GetSection(“ConnectionString”).Value
};
services.AddDbContext(选项=>
options.UseSqlServer(Connections.GetSqlConnectionString(creds));
我已宣布两项服务如下:

services.AddScoped<IConnections, Connections>();

services.AddScoped<IConfiguration>(sp =>
            {
                IConfigurationBuilder configurationBuilder = new ConfigurationBuilder();
                configurationBuilder.AddJsonFile("appsettings.json");
                return configurationBuilder.Build();
            });
services.addScope();
services.AddScoped(sp=>
{
IConfigurationBuilder configurationBuilder=新的configurationBuilder();
configurationBuilder.AddJsonFile(“appsettings.json”);
返回configurationBuilder.Build();
});
所以我看了一些关于将进程内更改为进程外的帖子(特别是[this]),但是这给了我其他奇怪的问题。我不知道当我在引擎盖下做这些改变时会发生什么变化,这已经让我发疯好几天了

我在2.2中启动了API,但现在是3.1.1,我也从csproj文件中删除了所有2.2引用

如果我按照另一篇“相关”帖子的建议将属性更改为OutOfProcess,我会得到以下结果:

string[] creds =
            {
                        Configuration.GetSection("ApplicationCreds").GetSection("appId").Value,
                        Configuration.GetSection("ApplicationCreds").GetSection("appToken").Value,
                        Configuration.GetSection("ConnectionString").GetSection("connectionString").Value
            };
            services.AddDbContext<InternalReportsContext>(options =>
                options.UseSqlServer(Connections.GetSqlConnectionString(creds)));

似乎与我的问题非常接近,但我无法确定哪个引用依赖于Core2.2。我已经从csproj中删除了所有的2.2引用,我没有看到任何在我的引用中跳出的东西。或者我找错地方了


这是否回答了您的问题@hotel我读过这篇文章,试图对csproj进行建议的更改,并将属性更改为OutProcess,但它会出现其他一些古怪的弹出错误,甚至不会在本地启动API。您是否为您的.net core版本安装了托管包?我已经安装了5.0,因为我正在尝试更新一些Nuget软件也许我只是在一些事情上过时了。我没有考虑过这样做,因为在我做出这些看似无害的改变之前,它是有效的,我不明白为什么如此简单的事情会导致如此严重的问题。我会找到3.1版的托管包并尝试一下。@hotel-No-joy-on-the-stick。我做了一个重建和IIS设置,以确保我得到了相同的错误。Windows错误日志也相同。