GithubHelp home page GithubHelp logo

Comments (8)

markjprice avatar markjprice commented on May 2, 2024

The exception message is "Must specify valid information for parsing in the string" and this is generated by Enum.TryParse so that sounds like you have entered an invalid value for the Level e.g. it can only be Info, Error, Warning, and so on or an integer value like 0, 1, 2, and so on.

Please show the contents of your file named appsettings.json. It should be:

{
  "PacktSwitch": {
    "Level": "Info"
  }
}

from cs11dotnet7.

bettesn avatar bettesn commented on May 2, 2024

from cs11dotnet7.

markjprice avatar markjprice commented on May 2, 2024

Sorry, but I cannot help unless I have more information. The exception you got says it cannot parse the string value for the enum. That could be because you are looking at one file but it is reading a different one. Or the value is wrong. Please show as much information as possible, for example, the code will output the full path and filename of the appsettings.json file that it is reading from. Please show all output and the contents of that file.

from cs11dotnet7.

bettesn avatar bettesn commented on May 2, 2024

from cs11dotnet7.

Matrix-Zhang avatar Matrix-Zhang commented on May 2, 2024

@markjprice same issue, the json key is 'PacktSwitch:Level'?
图片

from cs11dotnet7.

huynhloc-1110 avatar huynhloc-1110 commented on May 2, 2024

It seems like the new version (7.0.3) of Microsoft.Extensions.Configuration.Binder has some changes that break the old code in the book. I also had the same issue as you and tried changing the version of the Binder in Instrumenting.csproj from 7.0.3 back to 7.0.0 to match the version in the book and it worked fine after that.
I also tried changing back to 7.0.3 again and the exception showed again.

Here is my package reference when the error happened:

  <ItemGroup>
    <PackageReference Include="Microsoft.Extensions.Configuration" Version="7.0.0" />
    <PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="7.0.3" />
    <PackageReference Include="Microsoft.Extensions.Configuration.FileExtensions" Version="7.0.0" />
    <PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="7.0.0" />
  </ItemGroup>

And after fixing:

  <ItemGroup>
    <PackageReference Include="Microsoft.Extensions.Configuration" Version="7.0.0" />
    <PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="7.0.0" />
    <PackageReference Include="Microsoft.Extensions.Configuration.FileExtensions" Version="7.0.0" />
    <PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="7.0.0" />
  </ItemGroup>

from cs11dotnet7.

markjprice avatar markjprice commented on May 2, 2024

Thank you, Huynh Loc Le, you are correct. I have tested all versions of the package from 7.0.0 to 7.0.3 and the latest that works is 7.0.2. I have created an errata item for this:
https://github.com/markjprice/cs11dotnet7/blob/main/docs/errata/errata.md#page-178---reviewing-project-packages

from cs11dotnet7.

bettesn avatar bettesn commented on May 2, 2024

from cs11dotnet7.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.