http://developer.xamarin.com/guides/ios/advanced_topics/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:

1
2
3
class Foo<T> : UIView {
[..]
}

While generic subclasses of NSObjects are possible, there are a few limitations. Read theGeneric subclasses of NSObject document for more information

P/Invokes in Generic Types

P/Invokes in generic classes aren't supported:

1
2
3
4
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/Mono IOS Limitations的更多相关文章

  1. Xamarin Mono For Android 4.6.07004 完整离线安装破解版(C#开发Android、IOS工具)

      Xamarin是由Miguel de Icaza成立的一家新的独立公司,目的是给Mono一个继续奋斗的机会.Mono for Android (原名:MonoDroid)可以让开发人员使用 Mic ...

  2. Xamarin Mono 环境搭建

    Xamarin Mono 环境搭建(使用Visual Studio 2013 开发android 和 ios ) 本文主要介绍Xamarin结合VS2013来开发Android应用程序,主要会介绍Mo ...

  3. Visual Studio 2013 Xamarin for iOS 环境搭建

    原文:Visual Studio 2013 Xamarin for iOS 环境搭建 一.Mac安装Xamarin.iOS 1,我的Mac 环境:OSX 10.10.3.Xcode 6.3.2 (使用 ...

  4. Xamarin Mono Android实现“再按一次退出程序”

    开始研究Android平台软件编程,Xamarin Mono for Android上手快,跨平台共享代码,代价是bug多多,是一味可口的毒药啊! 环境VS2012 + Xamarin Mono An ...

  5. Xamarin Mono For Android 4.6.07004看不到新建android

    有很多朋友安装了Xamarin Mono For Android 4.6.07004看不到新建android项目 PS 官方安装包有BUG,在某些情况下可能会出现丢失VS插件的情况 (遇到此BUG请下 ...

  6. Xamarin Mono 环境搭建(使用Visual Studio 2013 开发android 和 ios )

    本文主要介绍Xamarin结合VS2013来开发Android应用程序,主要会介绍Mono和Xamarin的关系,以及整个搭建环境的过程. 一.Mono和Xamarin介绍 1.Mono简介 Mono ...

  7. Xamarin Mono Android Ios 安装、破解(4.12)

    一.Windows下面的安装 1. 安装环境介绍: Win8.1 企业版64位.VS2013,mono-android-4.12.02001,下面的安装过程都是在VS2013已经安装成功之后的操作,本 ...

  8. mono ios莫名其妙闪退的解决方法

    使用mono进行ios开发也有一年了,一直有个头疼的问题是闪退,而且闪退的时候并没有抛出明确的错误. 前两天在调试一个bug的时候,在序列化的时候又莫名其妙的闪退,后来在一位大神(博客地址)的指导下, ...

  9. xamarin跨平台iOS、Android 与Windows

    http://xamarin.csdn.net/ Xamarin是一个行动App开发平台,提供跨平台开发能力,开发人员透过Xamarin开发工具与程序语言,即可开发出iOS.Android 与Wind ...

随机推荐

  1. CentOS 7下的KVM网卡配置为千兆网卡

    在KVM下可以生成两种型号的网卡,RTL8139和E1000,其实应该是底层生成不同芯片的网卡,而不是附带宿主机网卡是什么型号就是什么型号的,其中默认为100兆网卡,即RTL8319的螃蟹卡,另一种是 ...

  2. mongodb chunk 大小设置

    默认是64MB,取值范围是1 MB 到 1024 MB. 那改动会造成什么?下表简单总结: chunk size 调节 splitting次数(碎片数) 数据跨shard数目 数据均匀 网络传输次数 ...

  3. VS2015 打包winform 安装程序

    最近开发了一个小软件.由于需要打包.网上找了一些资料.然后整合了起来.希望对大家有所帮助.不全面请见谅. 打包控件 InstallShield-Limited-Edition  下面是注册地址 htt ...

  4. C#打印图片

    打印的原理是:生成mdi文件,系统碰到mdi的时候会自动以打印的方式处理.所以,不管用什么模板,什么方式:能在PrintPage事件处理中,生成一张要打印内容的图片就OK了! C#实现打印源码如下: ...

  5. PeekMessage和GetMessage函数的主要区别

    PeekMessage和GetMessage函数的主要区别 PeekMessage和GetMessage函数的主要区别有:1. GetMessage的主要功能是从消息队列中“取出”消息,消息被取出以后 ...

  6. 内存加载DLL

    1.前言 目前很多敏感和重要的DLL(Dynamic-link library) 都没有提供静态版本供编译器进行静态连接(.lib文件),即使提供了静态版本也因为兼容性问题导致无法使用,而只提供DLL ...

  7. Spring Boot开发之明月千城(一)

    原文地址:http://qindongliang.iteye.com/blog/2205633 最近数据分析的项目也即将告一段落了,中间也积累了很多知识,特此记录一下.其中用的最爽的Web组合开发就是 ...

  8. 【k8s】基础概念 + 工作原理

    工作原理: 原理图 工作原理描述: 1>用户通过kubectl或者API server的REST API接口,提交需要运行的docker容器(创建pod请求): 2>api server将 ...

  9. 用Service实现断点下载

     整体的思路: 在下载文件时,将进度写入数据库,同一时候通知该ContentProvider的观察者更新页面,这个通知过程不要太频繁.我设置了10次,否则页面会灰常卡. 假设异常中断(网络中断或程 ...

  10. 安装veloeclipse插件报错解决方案

    步骤: 1.把Eclipse安装目录下的artifacts.xml打开,搜索veloeclipse,把它相关的项删除: 2.Help 3. Install New Software 4.Work Wi ...