I have a very trivial method for deserialization of data from a file:
private static List<DataJSON> LoadJSON()
{
List<DataJSON> jsonData = new List<DataJSON>();
/*
using (StreamReader file = File.OpenText(@"actions.json"))
{
JsonSerializer serializer = new JsonSerializer();
jsonData = (List<DataJSON>)serializer.Deserialize(file, typeof(List<DataJSON>));
}*/
Console.WriteLine("a");
var file = File.ReadAllText("actions.json");
Console.WriteLine("b");
try
{
jsonData = JsonConvert.DeserializeObject<List<DataJSON>>(file);
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
Console.WriteLine("c");
return jsonData;
}
Which is working just fine on Windows machine. However, on linux (Debian 9) I am getting "Aborts". There is no exception thrown at all:
I have placed some additional console line outputs, and managed to track down the issue to this line:
List<DataJSON> jsonData = JsonConvert.DeserializeObject<List<DataJSON>>
is it possible for the dotnet to output something more meaningful than "Aborted"? What could be the cause of this issue?
App is compiled like this:
dotnet publish -c release --runtime linux-x64
Also dotnet --version
command output:
2.1.3
Edit: As it turns out - the issue is totally random. The JSON is de-serialized 3 times out of 10. Or 5 out of 10. It either works or not - randomly.
Edit 2. As it turns out - this issue has very little in common with Deserialization. The problem is the type of the object that is being de-serialized. I was able to reproduce the issue on multiple occasions just by doing this:
static void Main(string[] args)
{
Console.WriteLine("Start");
List<string> symbolsStr = new List<string>() {
"MODETH", "MTHETH", "MTLETH", "NANOETH", "NAVETH", "NEBLETH", "NEOETH",
"NULSETH", "OAXETH", "OMGETH", "OSTETH", "PIVXETH", "POEETH", "POWRETH",
"MDAETH", "PPTETH", "QTUMETH", "RCNETH", "RDNETH", "REQETH", "RLCETH",
"SALTETH", "SNGLSETH", "SNMETH", "SNTETH", "STEEMETH", "STORJETH", "STRATETH",
"SUBETH", "TNBETH", "QSPETH", "TNTETH", "MCOETH", "LUNETH", "CNDETH"};
foreach (var item in symbolsStr)
{
var symbol = (Symbol)item;
}
Console.WriteLine("End");
Environment.Exit(0);
}
When the string
is converted to Symbol
type of object - Abort is happening (presumably). The causes of it are unknown to me. Also, the reason why exception is not shown is also unknown. I'd still appreciate to hear out any advices on how to debug this issue. In a meanwhile - I have contacted the creator of a library (C# Binance API by sonvister) which seems to be misbehaving on my machine. I will keep this post updated.