'registering services in ConfigureServices method is giving error

I am trying to register one services in ConfigureServices method like below

public void ConfigureServices(IServiceCollection services)
    {
        services.AddTransient<FeatureToggle>(x => new FeatureToggle{ 
            DeveloperException = configuration.GetValue<bool>("FeatureToggles:DeveloperExceptions")
        });

        services.AddMvc();            
    }

But while debugging I am getting error as given in the image below

enter image description here

The error was generated after adding line

services.AddMvc();



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source