Closed KseinyaR-STCU closed 4 years ago
You can repro this with a new empty Net Core 3.0 Web Application.
Adding a reference to AutoMapper.Extensions.Microsoft.DependencyInjection, any resolver (I have a basic boolean one), and a services.AddAutoMapper
in the Startup.cs recreates the error.
I think this is better suited for StackOverflow.
@lbargaoanu How is this a StackOverflow question? I'm not asking how to do something.
Automapper works great in Net Core 2. Updating to Net Core 3, without any other changes at all, breaks Automapper. Unless you only support Net Core 2, this seems like an issue.
I narrowed the error down on resolvers that use DataRow.
public class BooleanValueFromDataRowResolver : IValueResolver<DataRow, object, bool>
{
private readonly string initValue;
public BooleanValueFromDataRowResolver(string initValue) => this.initValue = initValue;
public bool Resolve(DataRow source, object destination, bool destMember, ResolutionContext context) =>
((string)source[initValue])?.Equals("Y") ?? false;
}
Why is your resolver accepting a string as its constructor? That means it needs a string dependency.
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
NetCore is moving from the old WebHostBuilder to a new HostBuilder. In the Program.cs that now looks like this:
This breaks all the
services.AddAutoMapper
usages we have.Not sure if this is an issue within AutoMapper itself or the NetCore HostBuilder, but considering they are deprecating their old WebHostBuilder (which works fine), this will need to be fixed on some side.
The error thrown is: