简体   繁体   English

如何诊断 .net core ANCM 进程内启动失败

[英]How to diagnose .net core ANCM In-Process Start Failure

I recently upgraded from dotnet core 2.2 to 3.1 on my solution.我最近在我的解决方案上从 dotnet core 2.2 升级到 3.1。 I've been able to create another solution and get that running with 3.1 but with my .net core web app I'm having troubles.我已经能够创建另一个解决方案并让它在 3.1 上运行,但是我的 .net 核心 Web 应用程序遇到了麻烦。 (running on local IISExpress) (在本地 IISExpress 上运行)

I keep getting the error: HTTP Error 500.30 - ANCM In-Process Start Failure我不断收到错误消息: HTTP Error 500.30 - ANCM In-Process Start Failure

After removing all 2.X instances of AspNetCore from my solution and performing the suggested code changes from Microsoft I still keep getting the error.从我的解决方案中删除 AspNetCore 的所有 2.X 实例并执行 Microsoft 建议的代码更改后,我仍然收到错误消息。 I've looked in the event log in which these are my only two notifications:我查看了事件日志,其中只有两个通知:

1. Application '/LM/W3SVC/2/ROOT' with physical root 'C:\\Repositories\\X\\X\\' hit unexpected managed exception, exception code = '0xe0434352'. Please check the stderr logs for more information. 1. Application '/LM/W3SVC/2/ROOT' with physical root 'C:\\Repositories\\X\\X\\' hit unexpected managed exception, exception code = '0xe0434352'. Please check the stderr logs for more information. Application '/LM/W3SVC/2/ROOT' with physical root 'C:\\Repositories\\X\\X\\' hit unexpected managed exception, exception code = '0xe0434352'. Please check the stderr logs for more information.

2. Application '/LM/W3SVC/2/ROOT' with physical root 'C:\\Repositories\\X\\X\\' failed to load clr and managed application. CLR worker thread exited prematurely 2. Application '/LM/W3SVC/2/ROOT' with physical root 'C:\\Repositories\\X\\X\\' failed to load clr and managed application. CLR worker thread exited prematurely Application '/LM/W3SVC/2/ROOT' with physical root 'C:\\Repositories\\X\\X\\' failed to load clr and managed application. CLR worker thread exited prematurely

I even tried setting up some try/catch blocks to see if an exception was thrown, with no avail.我什至尝试设置一些 try/catch 块来查看是否抛出异常,但无济于事。

So my question is: How do you debug what's going wrong with the configure services?所以我的问题是:你如何调试配置服务出了什么问题?


edit: Startup.cs编辑:Startup.cs

using System;
using Microsoft.AspNetCore.Authentication.Cookies;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using PoncaHillsPumpkins.Config;
using PoncaHillsPumpkins.Data.Services;
using PHP.Core.Entities;
using Stripe;
using PHP.Models.Stripe;
using PHP.Models.SendGrid;
using PoncaHillsPumpkins.Config.EmailSender;
using PHP.Utilities.Triggers;
using PHP.DAL;
using PHP.Utilities.Email.SendGrid;
using System.Net.Http;
using PHP.Models.Google.Maps;
using PHP.Utilities.Maps.GoogleMaps;
using PoncaHillsPumpkins.Data.Department;
using PHP.Utilities.Maps;
using ElmahCore.Mvc;
using ElmahCore.Sql;
using ElmahCore.Mvc.Notifiers;
using PoncaHillsPumpkins.Config.CustomExceptionMiddleware.Extensions;
using Microsoft.AspNetCore.Identity.UI.Services;
using Microsoft.Extensions.Hosting;

namespace PoncaHillsPumpkins
{
    public class Startup
    {
        public Startup(IConfiguration configuration)
        {
            Configuration = configuration;
        }

        public IConfiguration Configuration { get; }

        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            DbConnectionString.ConnectionString = Configuration.GetConnectionString("DefaultConnection");

            services.AddDbContextPool<ApplicationDbContext>(options =>
                options.UseSqlServer(
                    Configuration.GetConnectionString("DefaultConnection")));

            services.AddIdentity<ApplicationUser, ApplicationRole>()
                .AddRoles<ApplicationRole>()
                .AddRoleManager<RoleManager<ApplicationRole>>()
                .AddEntityFrameworkStores<ApplicationDbContext>()
                .AddDefaultTokenProviders(); //2FA

            services.AddTransient<ApplicationDbContext>();
            services.AddTransient<HttpClient>();

            /*
            services.AddAuthorization(options =>
            {
                options.AddPolicy("TestPolicy", policy => policy.RequireRole("Admin"));
            });*/

            services.Configure<CookiePolicyOptions>(options =>
            {
                options.CheckConsentNeeded = context => true;
                options.MinimumSameSitePolicy = SameSiteMode.None;
            });

            services.Configure<IdentityOptions>(options =>
            {
                options.Password.RequireDigit = true;
                options.Password.RequireLowercase = true;
                options.Password.RequireNonAlphanumeric = true;
                options.Password.RequireUppercase = true;
                options.Password.RequiredLength = 8;
                options.Password.RequiredUniqueChars = 1;

                options.Lockout.DefaultLockoutTimeSpan = TimeSpan.FromMinutes(15);
                options.Lockout.MaxFailedAccessAttempts = 5;
                options.Lockout.AllowedForNewUsers = true;

                options.User.AllowedUserNameCharacters =
                "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-._@+";
                options.User.RequireUniqueEmail = true;

                options.SignIn.RequireConfirmedEmail = true;
            });

            //For Account Manage
            services.AddScoped<UserProfileService>();

            services.Configure<CookiePolicyOptions>(options =>
            {
                options.CheckConsentNeeded = context => false;
                options.MinimumSameSitePolicy = SameSiteMode.None;
            });

            services.ConfigureApplicationCookie(options =>
            {
                options.Cookie.Name = "JSI_Auth";
                options.Cookie.HttpOnly = true;
                options.ExpireTimeSpan = TimeSpan.FromMinutes(15);

                options.LoginPath = "/Identity/Account/Login";
                options.AccessDeniedPath = "/Identity/Account/AccessDenied";
                options.ReturnUrlParameter = CookieAuthenticationDefaults.ReturnUrlParameter;
                options.SlidingExpiration = true;
            });

            services.AddControllersWithViews(options => options.EnableEndpointRouting = false);
            services
                .AddRazorPages() //config.Filters.Add(new Config.Filters.PreviousURLFilter());
                .AddNewtonsoftJson(options =>
                {
                    options.SerializerSettings.Formatting = Newtonsoft.Json.Formatting.Indented;
                    options.SerializerSettings.ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore;
                    options.SerializerSettings.ContractResolver = new Newtonsoft.Json.Serialization.DefaultContractResolver();
                });

            services.AddMemoryCache();
            services.AddSession(session => {
                session.Cookie.IsEssential = true;
                session.IdleTimeout = TimeSpan.FromMinutes(30);
            });

            #region ExternalServices
            services.Configure<StripeSettings>(Configuration.GetSection("Stripe"));
            services.Configure<GoogleMapsSettings>(Configuration.GetSection("GoogleMaps"));
            services.Configure<SendGridAuthMessageSender>(Configuration.GetSection("SendGrid"));

            services.AddTransient<IEmailSender, SendGridEmailSender>();
            services.AddSingleton<SendGridMailer>();
            services.AddSingleton<GoogleMapsService>();
            #endregion

            services.Configure<TriggerSystemOptions>(options => { options.Triggers = TriggerConfig.Register(); });
            services.AddSingleton<TriggerSystem>();

            //Department & Location Services
            services.AddSingleton<OrderDepartment>();
            services.AddSingleton<AddressService>();

            services.Configure<ApiBehaviorOptions>(options =>
            {
                options.SuppressConsumesConstraintForFormFileParameters = true;
                options.SuppressInferBindingSourcesForParameters = true;
                options.SuppressModelStateInvalidFilter = true;
            });

            var mailOptions = new EmailOptions
            {
                MailSender = "noreply@X.com",
                MailRecipient = "X@X.com",
                SendYsod = true,
                SmtpServer = "localhost"
            };

            /*
            services.AddElmah<SqlErrorLog>(options =>
            {
                //options.Path = ""
                options.CheckPermissionAction = context => context.User.IsInRole("Admin");
                options.ConnectionString = Configuration.GetConnectionString("DefaultConnection");
                options.Notifiers.Add(new ErrorMailNotifier("Email", new EmailOptions() { SendYsod = true, MailRecipient = "X@X" }));
            });*/
        }

        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
        {
            StripeConfiguration.ApiKey = Configuration.GetSection("Stripe")["SecretKey"];

            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
                //app.UseDatabaseErrorPage();
            }
            else
            {
                //app.UseExceptionHandler("/Home/Error");
                app.UseHsts();
            }

            app.UseHttpsRedirection();
            app.UseStaticFiles();
            app.UseCookiePolicy();

            app.UseSession();
            app.UseAuthentication();

            app.ConfigureCustomExceptionMiddleware();

            app.UseRouting();
            app.UseAuthorization();
            app.UseEndpoints(endpoints =>
            {
                endpoints.MapHealthChecks("/healthz");
                endpoints.MapRazorPages();
                endpoints.MapDefaultControllerRoute();

                //endpoints.MapControllerRoute("default", "{controller=Home}/{action=Index}/{id?}");
            });
            //app.UseElmah();
        }
    }
}

Program.cs程序.cs

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;

namespace PoncaHillsPumpkins
{
    public class Program
    {
        public static void Main(string[] args)
        {
            CreateHostBuilder(args).Build().Run();
        }

        public static IHostBuilder CreateHostBuilder(string[] args) =>
            Host.CreateDefaultBuilder(args)
                .ConfigureWebHostDefaults(webBuilder =>
                {
                    webBuilder.UseStartup<Startup>();
                });
    }
}

Had exactly the same issue when deploying my Core 3.1 App to Azure App Service (x64) with IISExpress setting.使用 IISExpress 设置将我的 Core 3.1 应用程序部署到 Azure App Service (x64) 时遇到了完全相同的问题。 Very hard to find the internal (behind the scenes) error.很难找到内部(幕后)错误。

I don't know how to get this detailed debug log so I've solved it by switching from "Framework-Dependent" to "Self-Contained" a deployment.我不知道如何获得这个详细的调试日志,所以我通过从“框架相关”切换到“自包含”部署来解决它。 Hope this helps someone in the future.希望这对未来的人有所帮助。

It appears something with that shipped with the VS instance did not have the proper software/configuration to run under IIS Express. VS 实例附带的某些东西似乎没有在 IIS Express 下运行的正确软件/配置。 Simply switching debugger from that to the project allowed me to run on localhost (5001 port, similar to deployment).只需将调试器从那个切换到项目,我就可以在本地主机(5001 端口,类似于部署)上运行。

tl;dr - set the project as the debugger entrypoint. tl;dr - 将项目设置为调试器入口点。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 ANCM 进程中启动失败 - ANCM In-Process Start Failure IIS 和 NET Core HTTP 错误 500.30 - ANCM 进程中启动失败 .net 核心 3.1 - IIS and NET Core HTTP Error 500.30 - ANCM In-Process Start Failure .net core 3.1 HTTP 错误 500.30 - ANCM 进程中启动失败 Asp.net-Core 3.1 - HTTP Error 500.30 - ANCM In-Process Start Failure Asp.net-Core 3.1 ASP.NET 核心 3.1 - HTTP 错误 500.30 - ANCM 进程中启动失败 - ASP.NET Core 3.1 - HTTP Error 500.30 - ANCM In-Process Start Failure .NET 核心托管到 IIS,我收到 HTTP 错误 500.30 - ANCM 进程内启动失败 - .NET Core hosting to IIS, I get HTTP Error 500.30 - ANCM In-Process Start Failure ASP.NET 核心 3.0 - InProcess 与 OutOfProcess(HTTP 错误 500.30 - ANCM 进程内启动失败) - ASP.NET Core 3.0 - InProcess vs. OutOfProcess (HTTP Error 500.30 - ANCM In-Process Start Failure) .Net Core 3.0 HTTP 错误 500.30 - 尝试在启动 class 中添加 AddHostedService() 时,ANCM 进程内启动失败 - .Net Core 3.0 HTTP Error 500.30 - ANCM In-Process Start Failure When trying to add AddHostedService() in startup class ASP.NET Core 3 Web应用程序,Azure App Service和ANCM进程内处理程序加载失败 - ASP.NET Core 3 Web Application, Azure App Service, and a ANCM In-Process Handler Load Failure .NET 内核 HTTP 错误 500.0 - ANCM 进程内处理程序加载失败 - .NET Core HTTP Error 500.0 - ANCM In-Process Handler Load Failure HTTP 错误 500.30 - ANCM 进程中启动失败 - HTTP Error 500.30 - ANCM In-Process Start Failure
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM