I don't know if it's a bug or if it's me who do not use ES3 correctly, but here is my problem:
When I use ES3File to load an empty file (using the command 'new ES3File(FileName, true);'), it throw an exception because the file is not a proper json file, which is true.
The problem is that the file stays open and I get an access violation when I try to delete it (my goal is to re-create properly automatically).
Is there a way to close the underlying file after an exception occurred?
And anyway, I think it would be very interesting to properly close the file when any exception occurs, in order to provide to the user a clean state so he can process the exception correctly (and I don't see any situation where ES3 would throw an exception and it would be interesting for it to keep the file open).
Management of bad json files
Re: Management of bad json files
Hi there,
It looks like you've discovered an edge case in C# where a using block won't dispose of it's underlying stream if an exception occurs in it's constructor (despite Microsoft's own documentation mentioning nothing about this).
It's an easy fix at our end and will be resolved in the next update. In the meantime I'll PM you an update.
All the best,
Joel
It looks like you've discovered an edge case in C# where a using block won't dispose of it's underlying stream if an exception occurs in it's constructor (despite Microsoft's own documentation mentioning nothing about this).
It's an easy fix at our end and will be resolved in the next update. In the meantime I'll PM you an update.
All the best,
Joel
Re: Management of bad json files
I'm quite good at finding bugs, I'm not sure it's a blessing or a curse...
Thanks for the fix, it works fine now.
And I'd like to say that it's amazing how fast you're reacting, I appreciate.
About 'using', it's because the 'ES3Reader.Create()' call is not part of the 'using' statement.
This code:
I got the information here: https://docs.microsoft.com/en-us/dotnet ... -statement
I think that it's been intended by Microsoft that the constructors must no fail, and then you call an 'Init()' method inside the using if necessary.
Thanks for the fix, it works fine now.
And I'd like to say that it's amazing how fast you're reacting, I appreciate.
About 'using', it's because the 'ES3Reader.Create()' call is not part of the 'using' statement.
This code:
using (Font font1 = new Font("Arial", 10.0f)) { byte charset = font1.GdiCharSet; }Translates as:
{ Font font1 = new Font("Arial", 10.0f); try { byte charset = font1.GdiCharSet; } finally { if (font1 != null) ((IDisposable)font1).Dispose(); } }As you can see, the font creation is out of the 'try-catch', so if it fails then Dispose won't be called.
I got the information here: https://docs.microsoft.com/en-us/dotnet ... -statement
I think that it's been intended by Microsoft that the constructors must no fail, and then you call an 'Init()' method inside the using if necessary.
Re: Management of bad json files
It was indeed that page which helped me solve the error originally, but that's for sending it my way anyway
All the best,
Joel
All the best,
Joel