billbogaiv / hybrid-model-binding

Provides the ability to bind models using both ModelBinder and ValueProvider in ASP.NET Core.
MIT License
104 stars 19 forks source link

IServiceCollection' does not contain a definition for 'AddHybridModelBinder' and the best extension method overload #33

Closed vinayakshettar closed 4 years ago

vinayakshettar commented 5 years ago

Severity Code Description Project File Line Suppression State Error CS1929 'IServiceCollection' does not contain a definition for 'AddHybridModelBinder' and the best extension method overload 'HybridMvcCoreBuilderExtensions.AddHybridModelBinder(IMvcBuilder)' requires a receiver of type 'IMvcBuilder'

billbogaiv commented 5 years ago

AddHybridModelBinder is part of the Microsoft.Extensions.DependencyInjection namespace. Make sure this using-statement is included in your Startup.cs. It's used like:

Startup.cs (via README)

public void ConfigureServices(IServiceCollection services)
{
    // Add framework services.
    services
        .AddMvc()
        .AddHybridModelBinder();
}
billbogaiv commented 4 years ago

Closing due to inactivity. Not sure what version of the library this error occurred, but using the latest it should not be a problem. The namespace associated with AddHybridModelBinder is the same as IServiceCollection. So, if you have access to the latter you should have access to both.