Error CS0121 : The call is ambiguous between the following methods or properties: "Microsoft.Extensions.DependencyInjection.OptionsBuilderExtensions.ValidateOnStart(Microsoft.Extensions.Options.OptionsBuilder)" and "Microsoft.Extensions.DependencyInjection.OptionsBuilderExtensions.ValidateOnStart(Microsoft.Extensions.Options.OptionsBuilder)"
(For Reference: CS0121 )
Now, for the life of me, I cannot see the difference between
Microsoft.Extensions.DependencyInjection.OptionsBuilderExtensions.ValidateOnStart(Microsoft.Extensions.Options.OptionsBuilder)
and
Microsoft.Extensions.DependencyInjection.OptionsBuilderExtensions.ValidateOnStart(Microsoft.Extensions.Options.OptionsBuilder)
It is used like this:
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
namespace SomeNamespace;
internal static class ServiceCollectionExtensions
{
public static IServiceCollection AddServiceBusMessaging(this IServiceCollection serviceCollection)
{
serviceCollection.AddOptions<SomeOptions>()
.Configure<IConfiguration>((s, c) =>
c.GetSection("SectionName").Bind(s))
.ValidateDataAnnotations()
.ValidateOnStart();
// Some more AddXyz() ...
return serviceCollection;
}
}
And I also cannot seem to find an additional overload.
Dotnet Version in use is 9.0102
It is used in a Function App targetting net7.0, v4, isolated
Research led me to this post in a github issue:
https://github.com/Azure/azure-sdk-for-net/issues/43206#issuecomment-2038403235
[...]
OptionsBuilderExtensions
was moved fromMicrosoft.Extensions.Hosting
intoMicrosoft.Extensions.Options
. If you have a newerMicrosoft.Extensions.Options
and an olderMicrosoft.Extensions.Hosting
you will run into this issue. Try doing this...
<PackageReference Include="Microsoft.Extensions.Hosting" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Options" Version="8.0.0" />
[...]
(Emphasis by me)
That fixed the issue for me.