After adding services.AddOptions()
in ConfigureServices(IServiceCollection services)
the following error occurs:
CS0121
The call is ambiguous between the following methods or properties: Microsoft.Extensions.DependencyInjection.OptionsServiceCollectionExtensions.AddOptions(Microsoft.Extensions.DependencyInjection.IServiceCollection) and Microsoft.Extensions.DependencyInjection.OptionsServiceCollectionExtensions.AddOptions(Microsoft.Extensions.DependencyInjection.IServiceCollection)'
Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
...
public void ConfigureServices(IServiceCollection services)
{
...
services.AddOptions();
...
}
This is particularly strange as the ambiguity is between the same 'methods or properites'
Based on the feedback from this question I tracked down that I had a reference in project.lock.json
to "EntityFramework.MicrosoftSqlServer": "7.0.0-rc1-final"
which on its own has a reference to "Microsoft.Extensions.OptionsModel": "1.0.0-rc1-final"
The whole point is to have only references to "Microsoft.Extensions.Options": "1.0.0-rc2-final"
and remove all the ones to OptionsModel
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With