How to get Microsoft.Extensions.Configuration example to work?

Nicholas Piazza 501 Reputation points
2023-01-23T00:23:23.2333333+00:00

In the Microsoft documentation for .NET Platform Extension 7 in Microsoft.Extensions.Configuration.CommandLineConfigurationExtensions, I am unable to get the example for overload 2 of the AddCommandLine() method.

I am using the code block shown below and simulating command line arguments with the string[]. Other than that the code is the same as in the example. The problem is that the VS2022 compiler complains that 'ConfigurationBuilder' does not contain a definition for 'AddCommandLine' and no accessible extension method 'AddCommandLine' accepting a first argument of type 'ConfigurationBuilder' could be found. The packages for this project include Microsoft.Extensions.Configure (7.0.0) so the proper extensions should be configured. Any ideas why it doesn't recognize AddCommandLine (IConfigurationBuilder, String[]) extension method?



.NET
.NET
Microsoft Technologies based on the .NET software framework.
3,177 questions
{count} vote