나는이 .netcore 3.1
응용 프로그램을 내가으로 업데이트 할.net 5.0
다음 코드가 있습니다.
public static IAppSettings ConfigureAppSettings(this IServiceCollection services, IConfiguration configuration)
{
void ConfigureSection<Interface, Implementation>(string sectionName)
where Implementation : Interface, new() where Interface : class
{
Implementation configSection = new Implementation();
configuration.GetSection(sectionName).Bind(configSection);
services.AddSingleton<Interface>(configSection);
}
}
이전에는 작동했지만 .net5로 업데이트 한 후이 컴파일 타임 오류가 표시되기 시작합니다.
CS1061 'IConfigurationSection'에 'Bind'에 대한 정의가 포함되어 있지 않으며 'IConfigurationSection'유형의 첫 번째 인수를 허용하는 액세스 가능한 확장 메서드 'Bind'를 찾을 수 없습니다 (using 지시문 또는 어셈블리 참조가 누락 되었습니까?).
내 질문 : Bind
방법 의 대안은 무엇입니까 ?
이 Microsoft.Extensions.Configuration.Binder 패키지를 설치 했고 문제가 해결되었습니다.
이상한 점은 내가 사용 중일 때 .net-core3.1
설치할 필요가 Nuget
없었지만 업데이트 한 후에는 .net5
이 패키지를 별도로 설치해야한다는 것입니다.
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다