Я получил ошибку: InvalidOperationException: невозможно разрешить службу для типа «WebApplication4.InteraFaces.IAllClothes» при попытке активировать «WebApplication4.Controllers.ClothesController».
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using WebApplication4.Data;
using WebApplication4.Data.Mocks;
using WebApplication4.Data.Repository;
using WebApplication4.InteraFaces;
namespace WebApplication4
{
public class Startup
{
private IConfigurationRoot _confString;
public Startup(IWebHostEnvironment hostEnv)
{
_confString = new ConfigurationBuilder().SetBasePath(hostEnv.ContentRootPath).AddJsonFile("dbsettings.json").Build();
}
public void ConfigureServices(IServiceCollection services)
{
services.AddDbContext(options => options.UseSqlServer(_confString.GetConnectionString("DefaultConnection")));
services.AddTransient();
services.AddTransient();
services.AddMvc();
}
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
app.UseDeveloperExceptionPage();
app.UseStaticFiles();
app.UseStatusCodePages();
app.UseEndpoints(endpoints =>
{
endpoints.MapControllerRoute(
name: "default",
pattern: "{controller=Clothes}/{action=List}/{id?}");
});
}
}
}
Я получил ошибку: InvalidOperationException: невозможно разрешить службу для типа «WebApplication4.InteraFaces.IAllClothes» при попытке активировать «WebApplication4.Controllers.ClothesController». [code]using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Http; using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using WebApplication4.Data; using WebApplication4.Data.Mocks; using WebApplication4.Data.Repository; using WebApplication4.InteraFaces;
namespace WebApplication4 { public class Startup { private IConfigurationRoot _confString;
public Startup(IWebHostEnvironment hostEnv) { _confString = new ConfigurationBuilder().SetBasePath(hostEnv.ContentRootPath).AddJsonFile("dbsettings.json").Build(); }