1

I added Angular CLI to my project and everything was working. Then I decided to click the little flag at the top in Visual Studio 2017 which indicated that there is a new update for VS 2017. I installed it and restarted my Windows 10 PC.

Now it builds successfully using F6 however I'm getting the following error when I F5 or Ctrl+F5 my .net core mvc application in a browser:

screenshot: https://imgur.com/wFFN1r8

An error occurred while starting the application.

JsonReaderException: Invalid property identifier character: {. Path 'Logging', line 10, position 2. Newtonsoft.Json.JsonTextReader.ParseProperty()

FormatException: Could not parse the JSON file. Error on line number '10': '}, {'. Microsoft.Extensions.Configuration.FileConfigurationProvider.Load(bool reload)

JsonReaderException: Invalid property identifier character: {. Path 'Logging', line 10, position 2. Newtonsoft.Json.JsonTextReader.ParseProperty() Newtonsoft.Json.Linq.JContainer.ReadContentFrom(JsonReader r, JsonLoadSettings settings) Newtonsoft.Json.Linq.JContainer.ReadTokenFrom(JsonReader reader, JsonLoadSettings options) Newtonsoft.Json.Linq.JObject.Load(JsonReader reader, JsonLoadSettings settings) Microsoft.Extensions.Configuration.Json.JsonConfigurationFileParser.Parse(Stream input) Microsoft.Extensions.Configuration.Json.JsonConfigurationProvider.Load(Stream stream)

My appsettings.json file looks like:

{
   "Logging": {
    "IncludeScopes": false,
    "LogLevel": {
      "Default": "Warning"
     }
   }
}

I can't think of any other .json file that would be a problem. I removed the Angular client-app folder I added and it still produces the same error.

I have no clue where to begin with trying to solve this issue and Google isn't bringing up any other posts with the same issue.

Suggestions?

Lizzy
  • 2,033
  • 3
  • 20
  • 33
wf43fver
  • 89
  • 1
  • 2
  • 13
  • 1
    did you check your other config files? this one looks fine. – Daniel A. White Dec 14 '17 at 02:21
  • @DanielA.White I looked at all of my json files, startup.cs, program.cs, confirmed that all nuget packages are up to date. It's hard to diagnose because the build is successful so no red underlines anywhere and no errors in visual studio. Here's a screenshot of the error: https://imgur.com/wFFN1r8 – wf43fver Dec 14 '17 at 02:34
  • You might be able to enable Json.NET tracing globally to get a better idea of the problem. To enable tracing in `JsonSerializerSettings` see https://www.newtonsoft.com/json/help/html/SerializationTracing.htm. To modify settings globally see [Set default global json serializer settings](https://stackoverflow.com/q/21815759). But since the problem is happening in startup you'd have to do it early in the startup process... – dbc Dec 14 '17 at 02:37
  • It's odd that it's talking about line 10 when you don't have 10 lines in that file. My guess is that it's loading a different file than the one you think it is. If you look further up the stack trace and look at the local values, can you find the filename it's loading? – Jon Skeet Dec 14 '17 at 08:07
  • you have this problem with all your browsers or just some of them? – timo stevens Dec 14 '17 at 08:17
  • @timostevens: Given that it's a problem starting the web server, I don't see how there's a browser even involved... – Jon Skeet Dec 14 '17 at 08:20
  • @JonSkeet Yea I found that very odd as well. I don't see another file mentioned: https://imgur.com/wFFN1r8. Also I checked all of my json files, line 10 and don't see any issues. – wf43fver Dec 14 '17 at 13:35
  • Are you able to break into it in the debugger? I suspect you should be able to find a filename somewhere... – Jon Skeet Dec 14 '17 at 13:36
  • 1
    @RJay Do you have an `appsettings.Development.json` (or similar)? If Visual studio is starting your application in development environment, then it will be `appsettings.json` then reading `appsettings.Development.json` and applying values it finds in that json which are not included in the appsettings one. It's possible that the dev specific one has some invalid characters. – Jamie Taylor Dec 14 '17 at 13:36
  • @RJay Also related to this, do you have a `global.json` anywhere? This file can be used to tell Roslyn (I believe, or it might be the .NET Core SDK) which version of .NET Core to use when compiling or running your application. More information on it can be found here -> https://learn.microsoft.com/en-us/dotnet/core/tools/global-json – Jamie Taylor Dec 14 '17 at 13:38
  • 1
    appsettings.Development.json was the problem. Thanks @JamieTaylor! – wf43fver Dec 14 '17 at 14:05

2 Answers2

3

@Jamie Taylor figured it out.

The one file I didn't see since it doesn't appear in Solution Explorer unless you expand appsettings.json is "appsettings.Development.json".

I had:

{
  "Logging": {
    "IncludeScopes": false,
    "LogLevel": {
      "Default": "Debug",
      "System": "Information",
      "Microsoft": "Information"
    }
  },
  {
    "AWS": {
      "Profile": "Default",
      "Region": "us-east-1"
    }
  }
}

It was working earlier the same day and I can see in my windows file explorer that the file has not changed in the last 2 weeks. The formatting of this JSON file was incorrect. Since I don't need the AWS stuff anymore, I just deleted that part and now it's working as:

{
  "Logging": {
    "IncludeScopes": false,
    "LogLevel": {
      "Default": "Debug",
      "System": "Information",
      "Microsoft": "Information"
    }
  }
}
wf43fver
  • 89
  • 1
  • 2
  • 13
1

Please delete ( ) simbols on start and on end positions. It help my.

i get json as

( { result : "" } )

and it work now

{ result : "" }