Clr_e_unsupported_instruction

Hello,

When I want to display a TimeSpan using the .ToString() method, I get that exception :

Exception System.Exception - CLR_E_UNSUPPORTED_INSTRUCTION (1)

How to reproduce :

var duration = DateTime.UtcNow.Subtract(deb);
var str = duration.ToString();  // Exception thrown here
Debug.WriteLine("Duration : " + str); 

However, if I use the following syntax, I don’t get any exception :

var duration = DateTime.UtcNow.Subtract(deb);
Debug.WriteLine("Duration : " + duration); 

Does anyone have a solution to get a string that represents a TimeSpan ?

Regards,


Christophe

Is this tinyclr?

Yes. 0.12.0

Bug reproduced.

Workaround:

string str = "" + duration;
Debug.WriteLine("Duration: " + duration);

Merci Nicolas :wink:

Too simple workaround, I did not even think at this !

I will raise an issue on the repo.

Before I publish it, I have tested it because I think it was to simple too. But it did the trick ! :slight_smile:

Thanks for the find, this is the same known issue we’ve had for the past few releases. Take a look at the discussion around .constrained in the release notes.

You’re right as always. :wink: