I am using System.Text.Json to write my list of objects to json file. Getting below exception while calling JsonSerializer.Serialize
System.Text.Json
json
JsonSerializer.Serialize
System.TypeInitializationException: 'The type initializer for 'System.Text.Json.JsonSerializer' threw an exception.'
Inner exception:
TypeInitializationException: The type initializer for 'System.MemoryExtensions' threw an exception.
FileNotFoundException: Could not load file or assembly 'System.Runtime.CompilerServices.Unsafe, Version=4.0.4.1, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.
Any clue will be appreciated.
Solution: I was targeting lower version of .net 4.6.2 which was the reason for the crash. I upgraded to 4.8 and crash didn't happen.
2.1m questions
2.1m answers
60 comments
57.0k users