Xamarin.iOS,AOT,JIT,Limitations
Since applications on the iPhone using Xamarin.iOS are compiled to static code, it is not possible to use any facilities that require code generation at runtime.
These are the Xamarin.iOS limitations compared to desktop Mono:
Limited Generics Support
Unlike traditional Mono/.NET, code on the iPhone is statically compiled ahead of time instead of being compiled on demand by a JIT compiler.
Mono's Full AOT technology has a few limitations with respect to generics, these are caused because not every possible generic instantiation can be determined up front at compile time. This is not a problem for regular .NET or Mono runtimes as the code is always compiled at runtime using the Just in Time compiler. But this poses a challenge for a static compiler like Xamarin.iOS.
Some of the common problems that developers run into, include:
Generic Subclasses of NSObjects are limited
Xamarin.iOS currently has limited support for creating generic subclasses of the NSObject class, such as no support for generic methods. As of 7.2.1, using generic subclasses of NSObjects is possible, like this one:
class Foo<T> : UIView {
[..]
}
While generic subclasses of NSObjects are possible, there are a few limitations. Read the Generic subclasses of NSObject document for more information
P/Invokes in Generic Types
P/Invokes in generic classes aren't supported:
class GenericType<T> {
[DllImport ("System")]
public static extern int getpid ();
}
Property.SetInfo on a Nullable Type is not supported
Using Reflection's Property.SetInfo to set the value on a Nullable<T> is not currently supported.
Value types as Dictionary Keys
Using a value type as a Dictionary<TKey, TValue> key is problematic, as the default Dictionary constructor attempts to use EqualityComparer<TKey>.Default. EqualityComparer<TKey>.Default, in turn, attempts to use Reflection to instantiate a new type which implements the IEqualityComparer<TKey> interface.
This works for reference types (as the reflection+create a new type step is skipped), but for value types it crashes and burns rather quickly once you attempt to use it on the device.
Workaround: Manually implement the IEqualityComparer<TKey> interface in a new type and provide an instance of that type to the Dictionary<TKey, TValue> (IEqualityComparer<TKey>) constructor.
No Dynamic Code Generation
Since the iPhone's kernel prevents an application from generating code dynamically Mono on the iPhone does not support any form of dynamic code generation. These include:
- The System.Reflection.Emit is not available.
- No support for System.Runtime.Remoting.
- No support for creating types dynamically (no Type.GetType ("MyType`1")), although looking up existing types (Type.GetType ("System.String") for example, works just fine).
Reverse callbacks must be registered with the runtime at compile time.
System.Reflection.Emit
The lack of System.Reflection. Emit means that no code that depends on runtime code generation will work. This includes things like:
- The Dynamic Language Runtime.
- Any languages built on top of the Dynamic Language Runtime.
Remoting's TransparentProxy or anything else that would cause the runtime to generate code dynamically.
Important: Do not confuse Reflection.Emit with Reflection. Reflection.Emit is about generating code dynamically and have that code JITed and compiled to native code. Due to the limitations on the iPhone (no JIT compilation) this is not supported.
But the entire Reflection API, including Type.GetType ("someClass"), listing methods, listing properties, fetching attributes and values works just fine.
Reverse Callbacks
In standard Mono it is possible to pass C# delegate instances to unmanaged code in lieu of a function pointer. The runtime would typically transform those function pointers into a small thunk that allows unmanaged code to call back into managed code.
In Mono these bridges are implemented by the Just-in-Time compiler. When using the ahead-of-time compiler required by the iPhone there are two important limitations at this point:
- You must flag all of your callback methods with the MonoPInvokeCallbackAttribute
The methods have to be static methods, there is no support for instance methods.
No Remoting
The Remoting stack is not available on Xamarin.iOS.
Runtime Disabled Features
The following features have been disabled in Mono's iOS Runtime:
- Profiler
- Reflection.Emit
- Reflection.Emit.Save functionality
- COM bindings
- The JIT engine
Metadata verifier (since there is no JIT)
.NET API Limitations
The .NET API exposed is a subset of the full framework as not everything is available in iOS. See the FAQ for a list of currently supported assemblies.
In particular, the API profile used by Xamarin.iOS does not include System.Configuration, so it is not possible to use external XML files to configure the behavior of the runtime.
Xamarin.iOS,AOT,JIT,Limitations的更多相关文章
- Xamarin.iOS项目编译提示Could not AOT the assembly
Xamarin.iOS项目编译提示Could not AOT the assembly 错误信息:Could not AOT the assembly **************.dll 这个错误是 ...
- 【Xamarin挖墙脚系列:Xamarin.IOS机制原理剖析】
原文:[Xamarin挖墙脚系列:Xamarin.IOS机制原理剖析] [注意:]团队里总是有人反映卸载Xamarin,清理不完全.之前写过如何完全卸载清理剩余的文件.今天写了Windows下的批命令 ...
- Xamarin.iOS开发初体验
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAKwAAAA+CAIAAAA5/WfHAAAJrklEQVR4nO2c/VdTRxrH+wfdU84pW0
- xamarin IOS 报错处理: an error occurred on client Build420719 while
xamarin IOS 开发时如果报错如下: an error occurred on client Build420719 while...... 出现如下问题时,可能是1.丢失文件2.没有包括在项 ...
- Xamarin Studio在Mac环境下的配置和Xamarin.iOS常用控件的示例
看过好多帖子都是Win环境装XS,Mac只是个模拟器,讲解在Mac环境下如何配置Xamarin Studio很少,也是一点点找资料,东拼西凑才把Xamarin Studio装在Mac上跑起来,如下: ...
- Xamarin.IOS之多视图
欢迎大家加入以下开源社区 Xamarin-Cn:https://github.com/Xamarin-Cn Mvvmcross-Cn:https://github.com/Mvvmcross-Cn ...
- Xamarin.IOS之快速入门
欢迎大家加入以下开源社区 Xamarin-Cn:https://github.com/Xamarin-Cn Mvvmcross-Cn:https://github.com/Mvvmcross-Cn ...
- Xamarin.iOS编译出错
Xamarin.iOS编译出错 错误信息:C:/Program Files(x86)/Reference Assemblies/Microsoft/Framework/Xamarin.iOS/v1.0 ...
- [Xamarin.iOS] Visual Studio中Xamarin.iOS项目,无法加入PCL项目参考、NuGet组件参考
[Xamarin.iOS] Visual Studio中Xamarin.iOS项目,无法加入PCL项目参考.NuGet组件参考 解决方案 目前Visual Studio中最新版本的Xamarin.iO ...
随机推荐
- linux服务器账号密码正确无法登录
登录服务器时,发现密码错误,输入后还是错误不能登录 最后发现登录日志中有pam_tally2(sshd:auth): user root (0) tally 53, deny 6 less /var/ ...
- H2内嵌数据库使用步骤
1.找到h2数据库的jar包 D:\repositories\com\h2database\h2\1.4.187\h2-1.4.187.jar 2.双击jar包,配置连接信息 Driver Class ...
- WCF开发中将net.tcp协议寄宿到IIS的方法
1 部署IIS 1.1 安装WAS IIS原本是不支持非HTTP协议的服务,为了让IIS支持net.tcp,必须先安装WAS(Windows Process Activation Service),即 ...
- mysql索引 B+tree
一.B+tree示意图 二.为什么要用索引 1.索引能极大减少存储引擎需要扫描的数据量:因为索引有序所以可以快速查找并且不用全表查找: 2.索引可以把随机IO变为顺序IO:因为B+tree在数据中保存 ...
- Linux挂载qcow2格式的镜像
qcow2格式的镜像一般用于KVM/QEMU的hypervisor,当我们需要修改guest host内的一些配置而又不想启动VM时则可以通过挂载guest host进行修改. 需要安装的工具包: l ...
- Python PIL: cannot write mode RGBA as BMP(把有四位通道(RGBA)的图片换成有三位通道的(RGA))
图片png结尾的有四个通道RGBA,把四个通道改为三个通道(RGB),如下,bg为修改后的图片 img = Image.open('pic\\find.png')bg = Image.new(&quo ...
- MVC 6 电商网站开发实战
[原创] ASP.NET 5系列教程 (六): 在 MVC6 中创建 Web API 标签: Web API MVC6 创建web API | 博主:powertoolsteam ASP.NE ...
- 开源项目TypeScript
TypeScript 优秀开源项目大合集 TypeScript出来有段时间了,也冒出了很多用TypeScript开发的优秀开源项目,搜寻了一些基于TypeScript项目,分享给大家: https ...
- win10无线网连接 提示无法连接到此网络
一.Win10无法连接此网络是怎么回事 对于大多数遇到无法连接此网络问题的,主要是Win10笔记本电脑用户,使用的是无线网络.而出现Win10连接其他无线网络正常,但是就是某个无线网络无法正常连接的时 ...
- 什么是新生代 GC 和老年代 GC
GC 经常发生的区域是堆区,堆区还可以细分为新生代.老年代 jvm堆示意图 新生代 一个 Eden 区 两个 Survivor 区 老年代 默认 新生代(Young)与老年代(Old)的比例的值为 1 ...