N0xus N0xus - 3 months ago 10
C# Question

Outputting a sorted lists contents

I'm trying to output my dictionary values to a Unity string on the GUI (it's for a plug in). When I run my code without the data being outputted to the screen as a GUI label, it runs fine. No errors or anything, however, when I turn on the GUI code, I get the following message in Xcode:


ExecutionEngineException: Attempting to JIT compile method
'System.Linq.OrderedEnumerable
1<System.Collections.Generic.KeyValuePair
2>:GetEnumerator ()' while running with --aot-only.


I've never experienced this error before, and I'm confused as to what it means. I've googled it, but I couldn't find anything definitive on it.

This is my code as it stands:

private string dictionaryString = "I am here!!!!!";
var signalQuailty = dictionary.OrderBy(item => item.Value);

foreach( var v in signalQuailty)
{
// Issue line. I want the dictionary to output everything on the screen
// with every line on a new line
dictionaryString = "Key value: " + v.Key + " Value: " + v.Value + "\n";
}

void OnGUI()
{
GUI.Label (new Rect (10, 410, 1000, 20), dictionaryString);
}


Have I done anything wrong?
I don't get the message unless I turn on the string in the
foreach
loop.

Answer

It seems that OrderBy is not supported for the iOS target. A lot of people have problem using LINQ on iOS, and the general advice is to "use LINQ with care when targeting iOS":

Comments