ASP.NET не может добавить службу AutomapperC#

Место общения программистов C#
Anonymous
ASP.NET не может добавить службу Automapper

Сообщение Anonymous »

Я установил Automapper
< /code> и создал мой профиль (AutomapperConfigurationProfile.cs): < /p>
using AutoMapper;
using Invoices.Api.Models;
using Invoices.Data.Entities;

namespace Invoices.Api
{
public class AutoMapperConfigurationProfile: Profile
{
public AutoMapperConfigurationProfile()
{
CreateMap().ReverseMap();
}
}
}
< /code>
Он находится в той же папке, что и Program.cs. Но когда я хотел добавить Automapper в программу.Error CS1503 Argument 2: cannot convert from 'System.Type' to 'System.Action' Invoices.Api
< /code>
Это вся моя программа .cs: < /p>
using Invoices.Data.Repositories.Interfaces;
using Invoices.Data.Repositories;
using System.Text.Json;
using Invoices.Api;

var builder = WebApplication.CreateBuilder(args);

builder.Services.AddControllers();
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();

builder.Services.AddControllers()
.AddJsonOptions(options =>
{
options.JsonSerializerOptions.PropertyNamingPolicy = JsonNamingPolicy.CamelCase;
});

builder.Services.AddScoped();
builder.Services.AddAutoMapper(typeof(AutoMapperConfigurationProfile));

var app = builder.Build();

if (app.Environment.IsDevelopment())
{
app.UseSwagger();
app.UseSwaggerUI();
}

app.UseHttpsRedirection();
app.UseAuthorization();
app.MapControllers();

app.Run();
< /code>
Я не могу понять, почему. Большое спасибо


Подробнее здесь: https://stackoverflow.com/questions/797 ... er-service

Вернуться в «C#»