markjprice / cs11dotnet7

Repository for the Packt Publishing book titled "C# 11 and .NET 7 - Modern Cross-Platform Development Fundamentals" by Mark J. Price
566 stars 206 forks source link

Fix to the newer versions of Microsoft.Configuration.Extensions #73

Closed leozaur1808 closed 1 year ago

leozaur1808 commented 1 year ago

Previous workaround

Chapter: 4 Page Number: 181 Section Title: Reviewing project packages Step Number: 3 Problem to fix: Exception has occurred:

CLR/System.Reflection.TargetInvocationException
An unhandled exception of type 'System.Reflection.TargetInvocationException' occurred in System.Private.CoreLib.dll: 'Exception has been thrown by the target of an invocation.'
 Inner exceptions found, see $exception in variables window for more details.
 Innermost exception     System.ArgumentException : Must specify valid information for parsing in the string. Arg_ParamName_Name

Suggested solution: In appsettings.json change "Level" to "TraceLevel" Other useful information e.g. OS, coding tools, and so on: VSCode, Mac OS, Dotnet version 7.0.100, Microsoft.Extensions.Configuration version 7.0.0, Microsoft.Extensions.Configuration.Binder version 7.0.4, Microsoft.Extensions.Configuration.FileExtensions version 7.0.0, Microsoft.Extensions.Configuration.Json version 7.0.0

leozaur1808 commented 1 year ago

Unfortunately, the TraceTrace.WriteLineIf(); does not work with this solution, despite the fact that Program.cs does not crash.