1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

Blazorで何故かIConfiguration(ConfigurationManager)のDIができない(ビルドエラー:CS1929:'IConfiguration' に XXX の定義が含まれておらず、最も適している拡張メソッド オーバーロード YYYYY には 'IConfiguration' 型のレシーバーが必要です)

Last updated at Posted at 2022-12-22

コード

@page "/IConfiguration"
@using Microsoft.Extensions.Configuration
@inject IConfiguration config;

pg_con = @connection_str

@code {
    private string? connection_str;

    protected override void OnInitialized() {
        connection_str = config.GetConnectionString("db_con");
    }
}

ビルドエラー

  • 重大度レベル:エラー (アクティブ)
  • コード:CS1929
  • 説明:'IConfiguration' に 'GetConnectionString' の定義が含まれておらず、最も適している拡張メソッド オーバーロード 'ConfigurationExtensions.GetConnectionString(IConfiguration, string)' には 'IConfiguration' 型のレシーバーが必要です

【変更前】

IConfiguration.razor → 上記ビルドエラー

【変更後】

Iconf.razor → ビルドエラー解消

何故…?

razorのファイル名っての制限あるん?ドキュメント探しても見当たらん(´・ω・`)

1
1
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?