Aspnetcore: Configuring custom config section in RC2 (latest dev build)

Created on 23 Dec 2015  路  13Comments  路  Source: dotnet/aspnetcore

Hi

I had a running configuration with RC1 but as soon as I upgraded to RC2, there is a compile time error at

public void ConfigureServices(IServiceCollection services)
{
      services.Configure<RefDataConfigs>(Configuration.GetSection(REF_DATA_CONFIG_KEY));
}

Seems like IServiceCollection.Configure started taking Action whereas it used to take IConfigurationSection.

Error   CS1503  Argument 2: cannot convert from 'Microsoft.Extensions.Configuration.IConfigurationSection' to 'System.Action<MyCustomTyppe>'    

Is there any easy way to fix this or I have to write a function which will convert IConfigurationSection to my custom type?

Most helpful comment

The Configure method got moved to a different package. Add a reference to the Microsoft.Extensions.Options.ConfigurationExtensions package and add a using Microsoft.Extensions.DependencyInjection; if you aren't already doing so.

All 13 comments

The Configure method got moved to a different package. Add a reference to the Microsoft.Extensions.Options.ConfigurationExtensions package and add a using Microsoft.Extensions.DependencyInjection; if you aren't already doing so.

Thanks worked.

+1 Thanks worked for me too!

Works for me as well. After 10 hours of research, stumbled on this issue. Is this documented anywhere?

@Blackbaud-SteveBrush we usually post breaking changes like these to the Announcements repo (https://github.com/aspnet/Announcements/issues). But I can't tell if this change was ever documented.

@pranavkm can you add this change to the Announcements issues? This change is very hard to resolve as no blogpost mentions change to Options configuration when upgrading from RC1 to RC2, nor the Options repository mentions this.

This just helped me out as well, thanks.

@HaoK - was there an announcement for this change?

I think this should be included in the migration guide.

I agree with @taspeotis. I had a hard time upgrading my application because of this.

No, doesn't look like there was, I will file one now

Thanks @HaoK . Here's the announcement for the change - https://github.com/aspnet/Announcements/issues/180

It work for me after rewrite dependencie:
"Microsoft.Extensions.Options.ConfigurationExtensions": "1.0.1" to "1.0.0" version.
Thanks!

Was this page helpful?
0 / 5 - 0 ratings