net6 TeeChart doesn't read net472 TeeChart settings

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
Kris C
Newbie
Newbie
Posts: 59
Joined: Fri Jan 13, 2023 12:00 am

net6 TeeChart doesn't read net472 TeeChart settings

Post by Kris C » Thu Apr 13, 2023 10:12 pm

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.

Christopher
Guru
Posts: 1603
Joined: Fri Nov 15, 2002 12:00 am

Re: net6 TeeChart doesn't read net472 TeeChart settings

Post by Christopher » Fri Apr 14, 2023 8:50 am

Hello Kris,
Kris C wrote:
Thu Apr 13, 2023 10:12 pm
If you have any questions, please let me know.
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:
Screenshot from 2023-04-14 10-46-57.png
Screenshot from 2023-04-14 10-46-57.png (159.38 KiB) Viewed 7039 times
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.
Kris C wrote:
Thu Apr 13, 2023 10:12 pm
It seems some type of conversion mechanism is needed here.
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

Kris C
Newbie
Newbie
Posts: 59
Joined: Fri Jan 13, 2023 12:00 am

Re: net6 TeeChart doesn't read net472 TeeChart settings

Post by Kris C » Fri Apr 14, 2023 11:51 am

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

Christopher
Guru
Posts: 1603
Joined: Fri Nov 15, 2002 12:00 am

Re: net6 TeeChart doesn't read net472 TeeChart settings

Post by Christopher » Fri Apr 14, 2023 2:40 pm

Hello Kris,
Kris C wrote:
Fri Apr 14, 2023 11:51 am
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?
Not on a property-by-property basis, no. The only way I can think of is a try/catch on the SerializationException.
Kris C wrote:
Fri Apr 14, 2023 11:51 am
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?
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.
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

Kris C
Newbie
Newbie
Posts: 59
Joined: Fri Jan 13, 2023 12:00 am

Re: net6 TeeChart doesn't read net472 TeeChart settings

Post by Kris C » Fri Apr 14, 2023 3:25 pm

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

Post Reply