HTTP Error 500.30 - ANCM In-Process Start Failure

0

Czesc, macie jakis pomysl jak sobie poradzic z tym bledem ? Nwm jaki tez kod tu wrzucic zebyscie mieli jakiekolwiek spojrzenie na ten problem dlatego prosilbym o jakas sugestie co tu dodac. Ogolnie rzecz biorac apka jest w wersji .net core 2.2 i tu lezy problem bo gdy zrobilem bardzo podobna do niej apke ale w wersji 2.1.2 bodajze to wszystko dzialalo

1

Zainstaluj odpowiednią wersję ASP.NET Core/.NET Core: Runtime & Hosting Bundle i spróbuj czy pójdzie.

0

Aktualnie mam teraz taki blad HTTP Error 502.5 - Process Failure bo troche pozmienialem w kodzie i tamten zniknal.

Cos takiego mi wyrzuca

at Microsoft.EntityFrameworkCore.Utilities.Check.NotEmpty(String value, String parameterName)
at Microsoft.EntityFrameworkCore.SqlServerDbContextOptionsExtensions.UseSqlServer(DbContextOptionsBuilder optionsBuilder, String connectionString, Action1 sqlServerOptionsAction) at ProjectCars.Startup.<ConfigureServices>b__4_1(DbContextOptionsBuilder options) in C:\Users\admin\source\repos\Projects\ProjectCars\ProjectCars\Startup.cs:line 36 at Microsoft.Extensions.DependencyInjection.EntityFrameworkServiceCollectionExtensions.<>c__DisplayClass1_02.<AddDbContext>b__0(IServiceProvider p, DbContextOptionsBuilder b)
at Microsoft.Extensions.DependencyInjection.EntityFrameworkServiceCollectionExtensions.DbContextOptionsFactory[TContext](IServiceProvider applicationServiceProvider, Action2 optionsAction) at Microsoft.Extensions.DependencyInjection.EntityFrameworkServiceCollectionExtensions.<>c__DisplayClass10_01.<AddCoreServices>b__0(IServiceProvider p)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitFactory(FactoryCallSite factoryCallSite, ServiceProviderEngineScope scope)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor2.VisitCallSite(IServiceCallSite callSite, TArgument argument) at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitScoped(ScopedCallSite scopedCallSite, ServiceProviderEngineScope scope) at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor2.VisitCallSite(IServiceCallSite callSite, TArgument argument)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitConstructor(ConstructorCallSite constructorCallSite, ServiceProviderEngineScope scope)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor2.VisitCallSite(IServiceCallSite callSite, TArgument argument) at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitScoped(ScopedCallSite scopedCallSite, ServiceProviderEngineScope scope) at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor2.VisitCallSite(IServiceCallSite callSite, TArgument argument)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.DynamicServiceProviderEngine.<>c__DisplayClass1_0.<RealizeService>b__0(ServiceProviderEngineScope scope)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngine.GetService(Type serviceType, ServiceProviderEngineScope serviceProviderEngineScope)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngineScope.GetService(Type serviceType)
at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService(IServiceProvider provider, Type serviceType)
at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService[T](IServiceProvider provider)
at ProjectCars.Program.Main(String[] args) in C:\Users\admin\source\repos\Projects\ProjectCars\ProjectCars\Program.cs:line 31

0

Co masz w tej linii w Program.cs?

C:\Users\admin\source\repos\Projects\ProjectCars\ProjectCars\Program.cs:line 31
0

To wklej treść błędu, a nie sam stack trace.

0
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.ComTypes;
using System.Threading.Tasks;
using Microsoft.AspNetCore;
using Microsoft.AspNetCore.Hosting;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using ProjectCars.Models;

namespace ProjectCars
{
    public class Program
    {

        public static void Main(string[] args)
        {
            //CreateWebHostBuilder(args).Build().Run();

            var host = CreateWebHostBuilder(args).Build();

            using (var scope = host.Services.CreateScope())
            {
                var services = scope.ServiceProvider;
                try
                {
                    var context = services.GetRequiredService<AppDbContext>();        //<------------------------------- tutaj jest problem
                    context.Database.Migrate();
                    DbInitializer.Seed(context);
                }
                catch (Exception e)
                {
                    Console.WriteLine(e);
                    throw;
                }
            }
        }

        public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
            WebHost.CreateDefaultBuilder(args)
                .UseStartup<Startup>();
    }
}
0

Czy w pliku Startup.cs masz jakieś odwołanie to typu AppDbContext?

0

using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using BookListMVC.Models;   //Nalezy dodac samodzielnie przy tworzeniu ConnectionStringa
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.HttpsPolicy;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Design;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using ReflectionIT.Mvc.Paging;  //Paginacja

namespace BookListMVC
{
    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)
        {
            services.Configure<CookiePolicyOptions>(options =>
            {
                // This lambda determines whether user consent for non-essential cookies is needed for a given request.
                options.CheckConsentNeeded = context => true;
                options.MinimumSameSitePolicy = SameSiteMode.None;
            });

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

            services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2);

            //services.AddPaging();   //Paginacja

            services.AddPaging(options => {
                options.ViewName = "Bootstrap4";
                options.HtmlIndicatorDown = " <span>&darr;</span>";
                options.HtmlIndicatorUp = " <span>&uarr;</span>";
            });

        }

        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                app.UseExceptionHandler("/Home/Error");
                // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
                app.UseHsts();
            }

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

            app.UseMvc(routes =>
            {
                routes.MapRoute(
                    name: "default",
                    template: "{controller=Home}/{action=Index}/{id?}");
            });
        }
    }
}
1

Zamień

var context = services.GetRequiredService<AppDbContext>(); 
//na
var context = services.GetRequiredService<ApplicationDbContext>(); 

Albo w pliku Startup.cs

services.AddDbContext<ApplicationDbContext>(options =>
                options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection")));
//na
services.AddDbContext<AppDbContext>(options =>
                options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection")));

Mam przeczucie, że kod jest CTRL+C/CTRL+V ;-)
Który DbContext jest prawidłowy? ApplicationDbContext czy AppDbContext

0

Wkleilem jeden plik z kodem, wlasnie z tego pierwotnego projektu gdzie inaczaj nazwalem DbContext, w tym projekcie teraz nosi on nazwe AppDbContext i we wszystkich miejscach , ktore wymieniles zgadza sie niestety ://

0

Jezeli chcesz to moge tutaj wrzucic linka do repo z tym bo pewnie dosc ciezko tak analizowac bez calkowitego wgladu w prace

0

Dla mnie problem leży w nazywaniu DbContext.
Skoro we wszystkich miejscach się on zgadza to dlaczego w startup wczytujesz ApplicationDbContext, a w program AppDbContext. Gdzieś coś nie gra w nazywaniu skoro to jest "kopiowanka".
Zmień w Program.cs, w linijce 31

var context = services.GetRequiredService<AppDbContext>();

na

var context = services.GetRequiredService<ApplicationDbContext>();
0

To skąd tutaj masz ApplicationDbContext?

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

Tak wygladal oryginalnie ten plik w tym aktualnym projekcie, przypadkowo wyslalem z tego z, ktorego czesc byla kopiowana

using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.HttpsPolicy;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using ProjectCars.Models;

namespace ProjectCars
{
    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)
        {
            services.Configure<CookiePolicyOptions>(options =>
            {
                // This lambda determines whether user consent for non-essential cookies is needed for a given request.
                options.CheckConsentNeeded = context => true;
                options.MinimumSameSitePolicy = SameSiteMode.None;
            });

            services.AddDbContext<AppDbContext>(options => options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection")));
            services.AddTransient<ICarRepository, CarRepository>();
            services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1);
        }

        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                app.UseExceptionHandler("/Home/Error");
                // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
                app.UseHsts();
            }

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

            app.UseMvc(routes =>
            {
                routes.MapRoute(
                    name: "default",
                    template: "{controller=Home}/{action=Index}/{id?}");
            });
        }
    }
}
0

I dalej masz ten sam błąd i ten sam stacktrace?

0

tak, pokazac ci moze .csproj ? bo dokonywalem tam modyfikacji i moze przez to tak sie dzieje bo zmienilem AspNetCoreHostingModel na InProcess

0

zasugerowalem sie tym wpisem i stad ta zmiana, w web.config nie zmienialem nic jak cos
https://stackoverflow.com/questions/53811569/using-netcore-2-2-and-using-the-in-process-hosting-model

0

Wrzuć, może się przyda, ale mi się już pomysły skończyły. Musisz poczekać na kogoś mądrzejszego ode mnie. Ja odszedłem od Entity Framework w projektach

0

https://github.com/LilKeyboard/ProjectCars.git
Tu jest jakis problem z wersja .net mi sie wydaje bo wczesniej ten projekt tworzylem w wersji 2.1.2 chyba i nie bylo tam tego bledu

0

Czytalem ze opcja jakas jest downgrade na wczesniejsza wersje .net ale nie do konca wiem jak go zrobic bo moj osstatni downgrade duzo mi namieszal w projekcie bo zle go zrobilem

1

A tego nie musisz zmienić na 2.2?

services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1);

Ja piszę projekty pod 3.0 Preview + Angular bez EF. Łapie się już totalnie każdego szczegółu...

0

no niestety to nie to, myslisz ze dobrym pomyslem bedzie downgrade do .net core 2.1 ?

0

Weź może od 0 utwórz ten projekt w 2.2+

0

Czemu od 0 ?

0

Ale utworzylem go juz w 2.2 to po co jeszcze raz ?

0

Moge go wlasciwie utworzyc od 0 jeszcze raz ale co mialbym zmienic bo na ta chwile zrobilbym go tak samo, no moze tyle bym zmienil ze bylby w wersji 2.1 bo tak byl pierwotnie. Myslisz zeby tak sprobowac ?

4

Masz mnóstwo błędów, na przyszłość polecam robić jedną zmianę i sprawdzać czy działa i dopiero potem robić kolejną.

  1. W metodzie main w klasie Program wykomentowałeś metodę Run(), spoiler alert bez niej serwer nie wystartuje. dodaje na końcu maina host.Run();
  2. Chcesz uzywać migracji, a nie masz dodanego nugeta Microsoft.EntityFrameworkCore.Tools
  3. nie masz ani jednej migracji == nie masz bazy, dodaj startową migrację,, polecenie Add-Migration
  4. w metodzie seed nie możesz nadawać id przy tak zdefiniowanym modelu

title

1 użytkowników online, w tym zalogowanych: 0, gości: 1