将IConfiguration转换为ConfigurationManager

时间:2019-04-16 14:30:46

标签: c# .net-core

我目前正在将网络框架项目转换为网络核心项目。

为此,我需要App.Config,它是在Core-Project中作为appsettings.json创建的。

在旧项目中,配置调用如下进行。

MyClass settings = ConfigurationManager.GetSection("sectionname") as MyClass;

(来自https://github.com/Azure/azure-relay/tree/master/samples/hybrid-connections/dotnet/portbridge/PortBridgeClientAgent的叉子)

我已经在将ConfigurationBuilder用于网络核心。

但是我必须将IConfiguration转换为ConfigurationManager,不是吗?怎么样?

谢谢。

ConfigurationManager manager = configuration;

说:“无法将类型IConfiguration隐式转换为ConfigurationManager”。存在显式转换(您是否缺少演员表?)

0 个答案:

没有答案
相关问题