Linq 方法上发布模式下的 MonoTouch JIT 错误
我目前有一些代码,如下所示,使用 Linq 为我组织一些 IEnumerable。在发布模式下的设备上执行此代码(iOS 5.0.1、MonoTouch 5.0.1、Mono 2.10.6.1)时,出现异常
在使用 --aot-only 运行时尝试 JIT 编译方法“System.Linq.OrderedEnumerable`1:GetEnumerator()”。
生成此错误的代码是:
// List<IncidentDocument> documents is passed in
List<LibraryTableViewItemGroup> groups = new List<LibraryTableViewItemGroup>();
List<DocumentObjectType> categories = documents.Select(d=>d.Type).Distinct().OrderBy(s=>s.ToString()).ToList();
foreach(DocumentObjectType cat in categories)
{
List<IncidentDocument> catDocs = documents.Where(d => d.Type == cat).OrderBy(d => d.Name).ToList();
List<LibraryTableViewItem> catDocsTableItems = catDocs.ConvertAll(d => { return new LibraryTableViewItem{ Image = GetImageForDocument(d.Type), Title = d.Name, SubTitle = d.Description}; });
LibraryTableViewItemGroup catGroup = new LibraryTableViewItemGroup{ Name = GetCatName(cat), Footer = null, Items = catDocsTableItems };
groups.Add (catGroup);
}
此错误不会发生在用于发布|调试配置的模拟器中,或用于调试配置的设备上。我在 SO 此处 和 这里,但我不确定我是否理解它们在这个特定问题上如何适用于我。
I currently have some code as shown below that uses Linq to organize some IEnumerables for me. When executing this code on the device in release mode (iOS 5.0.1, MonoTouch 5.0.1, Mono 2.10.6.1) I get the exception
Attempting to JIT compile method 'System.Linq.OrderedEnumerable`1:GetEnumerator()' while running with --aot-only.
The code that generates this error is
// List<IncidentDocument> documents is passed in
List<LibraryTableViewItemGroup> groups = new List<LibraryTableViewItemGroup>();
List<DocumentObjectType> categories = documents.Select(d=>d.Type).Distinct().OrderBy(s=>s.ToString()).ToList();
foreach(DocumentObjectType cat in categories)
{
List<IncidentDocument> catDocs = documents.Where(d => d.Type == cat).OrderBy(d => d.Name).ToList();
List<LibraryTableViewItem> catDocsTableItems = catDocs.ConvertAll(d => { return new LibraryTableViewItem{ Image = GetImageForDocument(d.Type), Title = d.Name, SubTitle = d.Description}; });
LibraryTableViewItemGroup catGroup = new LibraryTableViewItemGroup{ Name = GetCatName(cat), Footer = null, Items = catDocsTableItems };
groups.Add (catGroup);
}
This error doesn't happen in the simulator for Release|Debug configurations, or on the device for the Debug configuration. I've seen a couple of similar threads on SO here and here, but I'm not sure I understand how they apply to me on this particular issue.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
可能有几件事。
使用完整 AOT 时,存在一些限制构建 iOS 应用程序,即确保运行时不会进行 JIT 处理(Apple 的限制)。即使消息看起来相同,每个消息也是不同的(即许多原因会导致这种情况)。不过,我们通常可以为他们建议一些简单的解决方法;
这也可能是 5.0.1 中的(已知)回归(在 5.0.2 中已修复)。这会产生一些额外的 AOT 故障,这些故障通常不是问题(或已经解决的问题)。
我建议您更新到 MonoTouch 5.0.2,看看它是否可以正确编译您的应用程序。如果没有,请在 http;//bugzilla.xamarin.com 上填写错误报告,并包含一个小型的、独立的测试用例来重复该问题(上述内容不够完整)。如果它在启用调试时有效,这似乎是一个有趣的测试用例。
It could be a few things.
There are some limitations when using full AOT to build iOS applications, i.e. ensuring that nothing will be JITted at runtime (an Apple restriction). Each one is different even if the message looks identical (i.e. many causes will lead to this). However there are generally easy workarounds we can suggest for them;
It could also be a (known) regression in 5.0.1 (which is fixed in 5.0.2). This produced a few extra AOT failures that are normally not issues (or already fixed issues).
I suggest you to update to MonoTouch 5.0.2 to see if it compiles correctly your application. If not then please fill a bug report on http;//bugzilla.xamarin.com and include a small, self-contained, test case to duplicate the issue (the above is not complete enough). It seems an interesting test case if it works when debugging is enabled.