Hello,
I have uploaded the sample project TeeChartImportOld.zip to the kris.culin@bentley.com email folder using the upload service.
In this sample, we are trying to read the settings saved with the net472 version of TeeChart (the circa 2009).
This is the exception that is occurring:
System.Text.Json.JsonReaderException
HResult=0x80131500
Message='0x00' is an invalid start of a value. LineNumber: 0 | BytePositionInLine: 0.
Source=System.Text.Json
StackTrace:
at System.Text.Json.ThrowHelper.ThrowJsonReaderException(Utf8JsonReader& json, ExceptionResource resource, Byte nextByte, ReadOnlySpan`1 bytes)
It appears it is expecting json but the old net472 isn't storing the settings in json.
We are in the process of migrating our code base to target both net472 and net6. The net6 build will be used in a special platform and it will have the ability to open models that have setting saved with the older TeeChart. Being able to open graphs restoring these settings is essential to our users.
It seems some type of conversion mechanism is needed here. Or at the very least, a way to determine if the settings are compatible with the net6 version.
If you have any questions, please let me know.
Kris Culin
Bentley Systems, Inc.
net6 TeeChart doesn't read net472 TeeChart settings
-
- Guru
- Posts: 1603
- Joined: Fri Nov 15, 2002 12:00 am
Re: net6 TeeChart doesn't read net472 TeeChart settings
Hello Kris,
TeeChart's Template Export format is not compatible, as things stand, between the .NET Framework 4.x versions and our .NET 5/6 versions. The reason for this is that the .NET Framework 4.x versions use the BinaryFormatter class which Microsoft does not recommend for production code: This strong recommendation was already made by the time we partially re-wrote TeeChart for .NET 5.0, and it was this which caused us to take the decision to drop BinaryFormatter in favour of JSON serialization.
As I say, at the moment no such mechanism is in place.
Best Regards,
Christopher Ireland / Development & Support Steema Software Avinguda Montilivi 33, 17003 Girona, Catalonia Tel: 34 972 218 797 http://www.steema.com |
Instructions - How to post in this forum |
Re: net6 TeeChart doesn't read net472 TeeChart settings
Hi Christopher,
I do recall seeing this when I was migrating our code.
Do you know of a way to determine if the settings being read are valid? Or should I just use a try/catch and if an exception is thrown, fall back to default settings?
Does the latest net472 version use the binary format or is it using the json format? If the current net472 version is using the binary format, is there a way we could instead use the json format so the settings are compatible between the net472 and net6 versions of TeeChart?
Kris
I do recall seeing this when I was migrating our code.
Do you know of a way to determine if the settings being read are valid? Or should I just use a try/catch and if an exception is thrown, fall back to default settings?
Does the latest net472 version use the binary format or is it using the json format? If the current net472 version is using the binary format, is there a way we could instead use the json format so the settings are compatible between the net472 and net6 versions of TeeChart?
Kris
-
- Guru
- Posts: 1603
- Joined: Fri Nov 15, 2002 12:00 am
Re: net6 TeeChart doesn't read net472 TeeChart settings
Hello Kris,
Not on a property-by-property basis, no. The only way I can think of is a try/catch on the SerializationException.
As things stand, there is no compatibility between the .NET Framework and .NET Core TeeChart versions with respect to template formats, unfortunately. The .NET Framework version uses BinaryFormatter, and the .NET Core version uses JsonSerializer. Of course there's no technical reason for not making the two compatible, it would be a business decision concerning time investment.Kris C wrote: ↑Fri Apr 14, 2023 11:51 amDoes the latest net472 version use the binary format or is it using the json format? If the current net472 version is using the binary format, is there a way we could instead use the json format so the settings are compatible between the net472 and net6 versions of TeeChart?
Best Regards,
Christopher Ireland / Development & Support Steema Software Avinguda Montilivi 33, 17003 Girona, Catalonia Tel: 34 972 218 797 http://www.steema.com |
Instructions - How to post in this forum |
Re: net6 TeeChart doesn't read net472 TeeChart settings
Thank you, Christopher, for that information. We'll need to see what we can do to make our users workflows smoother when switching between platforms in regard to graph persistence.
Kris
Kris