Exception System error when converting Timespan to String

I have a TimeSpan variable named runningTime
If a try: string sTestTime = runningTime.ToString();
I get an Exception System error.

yep, error message says it all… unsupported instruction. What would you like to know about that?

If I look with F2 to the metadata TimeSpan.ToString is listed, so it should be supported.

I confirm I am seeing the same thing here.

I think it is related to .constraint

1 Like

Hi Gus,
Glad you see the same. Does this mean you will work on it to solve it in a next version or do I have to find a workaround anyway?

We will work on it but you may want to work around this for now.

@Bauland is indeed correct, it is because of .constrained being not supported. Try casting the TimeSpan to object before calling ToString: ((object)timespan).ToString()

1 Like

I came to the forums to report this same issue, but searched first an found this thread. I can report it is still throwing an exception in TinyCLR version 2.1. I am calling TotalSeconds first, and then converting to string as a workaround.

Did you use latest firmware 6300?

Ah, maybe not. In TinyCLR config it says version 2.1.0.6000. That should be 2.1.0.6300?

Yes, it should be fixed in latest version, unless special case.

Sorry for the dumb question, but where do I get the new firmware from? I see in TinyCLR Config how to browse for the file, but don’t know where it would be.

Downloads (ghielectronics.com)

1 Like