It says that using value types as dictionary keys will “crashes and burns rather quickly on the device”, does that means I can’t use something like Dictionary<int, string> to make a string lookup table?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
It’s not so dramatic (no burn) or so automatic – but it can happen.
Apple does not allow JIT (just in time) compilation on devices. This means that everything must be pre-compiled (ahead of time) before being deployed to devices. This means a few limitations exists for MonoTouch that you would not have with .NET / Mono or Mono for Android.
In general the generated code for generics can be shared between different types. Sadly this is not possible for value types. This means the AOT (ahead of time) compiler must generate code for every value type being used.
In some cases the AOT compiler might not be able to detect every possible type that might be needed at runtime. This will cause an
EngineExecutionExceptionthat will point you to the offending code.At this stage you can try to:
hint the AOT compiler that the code is needed (i.e. add some code that will make the AOT compiler generates the required missing code); or
refactor the code, e.g. to avoid value types;
No, that will work. When you create an instance of
Dictionary<int, string>then it’s pretty straightforward for the AOT compiler to know what code needs to be generated.Problems generally occurs when nesting generics or when using code that does (e.g. LINQ queries with value types can generate such code).