I am getting following error when i am registering simple asp.net core 2.1 app
An error occurred while starting the application.
LamarMissingRegistrationException: No service registrations exist or can be derived for Microsoft.AspNetCore.Mvc.Internal.MvcRouteHandler
Lamar.IoC.Scope.GetInstance(Type serviceType)
LamarMissingRegistrationException: No service registrations exist or can be derived for Microsoft.AspNetCore.Mvc.Internal.MvcRouteHandler
Lamar.IoC.Scope.GetInstance(Type serviceType)
Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService(IServiceProvider provider, Type serviceType)
Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService<T>(IServiceProvider provider)
`Microsoft.AspNetCore.Builder.MvcApplicationBuilderExtensions.UseMvc(IApplicationBuilder` app, Action<IRouteBuilder> configureRoutes)
Microsoft.AspNetCore.Builder.MvcApplicationBuilderExtensions.UseMvcWithDefaultRoute(IApplicationBuilder app)
Newzer.Startup.Configure(IApplicationBuilder app, IHostingEnvironment env) in Startup.cs
app.UseMvcWithDefaultRoute();
Microsoft.AspNetCore.Hosting.ConventionBasedStartup.Configure(IApplicationBuilder app)
Microsoft.AspNetCore.Server.IISIntegration.IISSetupFilter+<>c__DisplayClass4_0.<Configure>b__0(IApplicationBuilder app)
Microsoft.AspNetCore.HostFilteringStartupFilter+<>c__DisplayClass0_0.<Configure>b__0(IApplicationBuilder app)
Microsoft.AspNetCore.Hosting.Internal.AutoRequestServicesStartupFilter+<>c__DisplayClass0_0.<Configure>b__0(IApplicationBuilder builder)
Microsoft.AspNetCore.Hosting.Internal.WebHost.BuildApplication()
I can see it's failing at UseMvc call in Configure method. Here is my Startup class
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)
public void ConfigureContiner(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.AddMvcCore().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");
app.UseHsts();
}
app.UseHttpsRedirection();
app.UseStaticFiles();
app.UseCookiePolicy();
app.UseMvc(routes =>
{
routes.MapRoute(
name: "default",
template: "{controller=Home}/{action=Index}/{id?}");
});
}
}
I am getting following error when i am registering simple asp.net core 2.1 app
An error occurred while starting the application. LamarMissingRegistrationException: No service registrations exist or can be derived for Microsoft.AspNetCore.Mvc.Internal.MvcRouteHandler
Lamar.IoC.Scope.GetInstance(Type serviceType)
I can see it's failing at UseMvc call in Configure method. Here is my Startup class
public class Startup { public Startup(IConfiguration configuration) { Configuration = configuration; }