Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error on Build: JsonException: '0x00' is an invalid start of a value

Tags:

c#

.net

.net-6.0

Using .NET FW 6 with VS 2022. When I try to build my project I'm getting this error....

JsonException: '0x00' is an invalid start of a value. Path: $ | LineNumber: 0 | BytePositionInLine: 0.
   at System.Text.Json.ThrowHelper.ReThrowWithPath(ReadStack& state, JsonReaderException ex)
   at System.Text.Json.Serialization.JsonConverter`1.ReadCore(Utf8JsonReader& reader, JsonSerializerOptions options, ReadStack& state)
   at System.Text.Json.JsonSerializer.ReadFromSpan[TValue](ReadOnlySpan`1 utf8Json, JsonTypeInfo jsonTypeInfo, Nullable`1 actualByteCount)
   at System.Text.Json.JsonSerializer.Deserialize[TValue](ReadOnlySpan`1 utf8Json, JsonSerializerOptions options)
   at Microsoft.AspNetCore.Razor.Tasks.StaticWebAssetsManifest.FromJsonBytes(Byte[] jsonBytes)
   at Microsoft.AspNetCore.Razor.Tasks.GenerateStaticWebAssetsManifest.PersistManifest(StaticWebAssetsManifest manifest)
   at Microsoft.AspNetCore.Razor.Tasks.GenerateStaticWebAssetsManifest.Execute()
JsonReaderException: '0x00' is an invalid start of a value. LineNumber: 0 | BytePositionInLine: 0.
   at System.Text.Json.ThrowHelper.ThrowJsonReaderException(Utf8JsonReader& json, ExceptionResource resource, Byte nextByte, ReadOnlySpan`1 bytes)
   at System.Text.Json.Utf8JsonReader.ConsumeValue(Byte marker)
   at System.Text.Json.Utf8JsonReader.ReadFirstToken(Byte first)
   at System.Text.Json.Utf8JsonReader.ReadSingleSegment()
   at System.Text.Json.Utf8JsonReader.Read()
   at System.Text.Json.Serialization.JsonConverter`1.ReadCore(Utf8JsonReader& reader, JsonSerializerOptions options, ReadStack& state)
    Website C:\Program Files\dotnet\sdk\6.0.200\Sdks\Microsoft.NET.Sdk.Razor\targets\Microsoft.NET.Sdk.Razor.StaticWebAssets.targets    411 

Line 411 of the file Microsoft.NET.Sdk.Razor.StaticWebAssets.targets is the top line of this....

    <GenerateStaticWebAssetsManifest
  Source="$(PackageId)"
  BasePath="$(StaticWebAssetBasePath)"
  Mode="$(StaticWebAssetProjectMode)"
  ManifestType="Build"
  ReferencedProjectsConfigurations="@(StaticWebAssetProjectConfiguration)"
  DiscoveryPatterns="@(StaticWebAssetDiscoveryPattern)"
  Assets="@(StaticWebAsset)"
  ManifestPath="$(StaticWebAssetBuildManifestPath)">
  </GenerateStaticWebAssetsManifest>

I tried reinstalling VS, the latest stable .NET 6 FW, tried clelaring the nuget cache and doing a 'dotnet restore', per this... NuGet.targets error : '.', hexadecimal value 0x00, is an invalid character after upgrade to .Net Core 2.1.1

Also I searched diligently online but could not find an answer. Do you have any idea? Thank you!

like image 642
WebDevGuy2 Avatar asked Oct 13 '25 03:10

WebDevGuy2


1 Answers

I had the exact same error message but my problem was caused by a corrupted

obj\Debug\net6.0\staticwebassets.build.json

in one of the project folders. I had to manually delete the obj folder. "Clean Solution" in Visual Studio did not solve the problem.

like image 91
Michael G. Avatar answered Oct 14 '25 16:10

Michael G.