leo*_*eox 2 .net-standard-2.0 asp.net-core-2.1
当我试图在ConfigurationBuilder上调用AddCommandLine()函数时,我收到指定的语法错误
项目是.NetStandard 2.0
环境:
代码段:
var config = new ConfigurationBuilder()
.AddEnvironmentVariables()
.AddCommandLine(args)
.Build();
Run Code Online (Sandbox Code Playgroud)
注意:尝试使用Microsoft.Extensions.Configuration中的ConfigurationBuilder
收到以下错误时:
'IConfigurationBuilder' does not contain a definition for 'AddCommandLine' and no extension method 'AddCommandLine' accepting a first argument of type 'IConfigurationBuilder'
Run Code Online (Sandbox Code Playgroud)
在Visual Studio中的Nuget包管理器控制台上运行以下命令
Install-Package -ProjectName MyProj Microsoft.Extensions.Configuration.CommandLine
Run Code Online (Sandbox Code Playgroud)
或者使用dotnet cli运行以下命令:
dotnet add myproj.csproj package Microsoft.Extensions.Configuration.CommandLine
Run Code Online (Sandbox Code Playgroud)
使用GenericHost时,各种扩展的参考错误可能很常见
使用GenericHost时,可以选择添加元数据包,例如:
用于ASP.NET Core 2.1的Microsoft.AspNetCore.App元数据包
| 归档时间: |
|
| 查看次数: |
1529 次 |
| 最近记录: |