我正在尝试使用 MonoTouch 在 Visual Studio 2012 下运行任务。我正在使用 ALPHA 频道并安装了最新版本。
解决方案中有 3 个项目: 1. 具有异步方法的 PCL(158 个目标平台) 2. Touch 3. Android
此代码编译,可以部署和执行。但是当我从 iPhone 客户端拨打电话时:
var asyncResult = await MyClass.DoStuff();
Console.WriteLine("doing stuff completed: " + asyncResult);
我得到以下结果:
System.PlatformNotSupportedException:不支持此平台
在等待部分代码。当我用Task.ContinueWith
- 相同的结果编写它时。
有趣的是不仅仅在 Visual Studio + MonoTouch 下工作。所有其他配置正确启动此代码(WIN+VS+Android、WIN+VS+Android、MAC+XS+iOS、MAC+XS+Android)
SDK 版本与最新的 ALPHA 版本同步。
异常详细信息:未处理的异常:
System.PlatformNotSupportedException: This platform is not supported.
2013-07-25 11:45:32.384 iPhone[1817:907] Unhandled managed exception: This platform is not supported. (System.PlatformNotSupportedException)
at System.ExecutionContextLightup.Run (System.ExecutionContextLightup executionContext, System.Action`1 callback, System.Object state) [0x00000] in <filename unknown>:0
at System.Runtime.CompilerServices.AsyncMethodBuilderCore+MoveNextRunner.Run () [0x00000] in <filename unknown>:0
at Microsoft.Runtime.CompilerServices.TaskAwaiter+<>c__DisplayClassa.<OnCompletedInternal>b__1 (System.Object state) [0x00000] in <filename unknown>:0
at MonoTouch.UIKit.UIKitSynchronizationContext+<Post>c__AnonStorey52.<>m__4E () [0x00000] in /Developer/MonoTouch/Source/monotouch/src/UIKit/UIKitSynchronizationContext.cs:24
at MonoTouch.Foundation.NSAsyncActionDispatcher.Apply () [0x00000] in /Developer/MonoTouch/Source/monotouch/src/shared/Foundation/NSAction.cs:87
at (wrapper managed-to-native) MonoTouch.UIKit.UIApplication:UIApplicationMain (int,string[],intptr,intptr)
at
MonoTouch.UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x0004c] in /Developer/MonoTouch/Source/monotouch/src/UIKit/UIApplication.cs:38
at iPhone.Application.Main (System.String[] args) [0x00001] in c:\Sources\Local\PCL_XN\iPhone\Main.cs:17
The program 'Mono' has exited with code 0 (0x0).
The program '[6760] iPhone.vshost.exe: Managed (v4.0.30319)' has exited with code -1 (0xffffffff).