App Settings .Net Core

后端 未结 2 1855
自闭症患者
自闭症患者 2021-01-17 05:15

I am trying to add an appsettings.json and followed a lot of tutorials and still can not do it.

I create appsettings.json

{
  \"option1\": \"value1_f         


        
2条回答
  •  梦谈多话
    2021-01-17 05:34

    Did you include the correct namespace?

    using Microsoft.Extensions.DependencyInjection;
    

    Also did you have a reference to?:

    Microsoft.Extensions.Options.ConfigurationExtensions
    

    In above Assembly we have:

    public static IServiceCollection Configure(this IServiceCollection services, IConfiguration config) where TOptions : class;
    

    Most probably you are using the extension method from Microsoft.Extensions.Options assembly (which is wrong)

    public static IServiceCollection Configure(this IServiceCollection services, Action configureOptions) where TOptions : class;
    

提交回复
热议问题