Notice (2018-05-24): bugzilla.xamarin.com is now in
Please join us on
Visual Studio Developer Community and in the
Mono organizations on
GitHub to continue tracking issues. Bugzilla will remain
available for reference in read-only mode. We will continue to work
on open Bugzilla bugs, copy them to the new locations
as needed for follow-up, and add the new items under Related
Our sincere thanks to everyone who has contributed on this bug
tracker over the years. Thanks also for your understanding as we
make these adjustments and improvements for the future.
Please create a new report on
Developer Community or GitHub with
your current version information, steps to reproduce, and relevant error
messages or log files if you are hitting an issue that looks similar to
this resolved bug and you do not yet see a matching new report.
When creating a generic type that has a Dictionary that uses the type's generic type parameter for its values' type, the AOT compiler doesn't construct the required Dictionary type, resulting in a runtime error on an iOS device when it tries to invoke the JIT compiler.
public class Foo<T>
private Dictionary<int, T> d = new Dictionary<int, T>();
var foo = new Foo<string>(); // Runtime error.
Writing code elsewhere to force construction of the Dictionary type with the required type parameters will work-around this problem.
Tested on MonoTouch 5.2.12.
Only happens when dictionary key is a value type (primitive or custom), and then happens even if IEqualityComparer is passed in constructor.
Another workaround is to make the dictionary field public, and access it in code e.g.
add this line to end of unit test in attached project.
int x = foo.dict.Count;
Fixed in master/mobile-master.