Main Site Documentation

Clr_e_unsupported_instruction


#1

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


#2

Is this tinyclr?


#3

Yes. 0.12.0


#4

Bug reproduced.

Workaround:

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

#5

Merci Nicolas :wink:

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

I will raise an issue on the repo.


#6

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


#7

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.


#8

You’re right as always. :wink: