我正在尝试为我的Portable Class Library添加await / async支持。 在我的Xamarin.iOS项目中,我创建了对PCL的引用(配置文件78)。 每次我试图调用PCL异步方法时:
var result = await new Class1().Do();
我收到以下错误(stacktrace):
System.PlatformNotSupportedException: This platform is not supported.
2014-03-29 17:48:06.634 HelloWorld5[2014:60b] 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__AnonStorey89.<>m__A9 () [0x00000] in /Developer/MonoTouch/Source/monotouch/src/UIKit/.pmcs-compat.UIKitSynchronizationContext.cs:24
at MonoTouch.Foundation.NSAsyncActionDispatcher.Apply () [0x00000] in /Developer/MonoTouch/Source/maccore/src/Foundation/.pmcs-compat.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/.pmcs-compat.UIApplication.cs:38
at HelloWorld5.Application.Main (System.String[] args) [0x00001] in c:\Downloads\HelloWorld5.BackgroundTest\HelloWorld5\HelloWorld5\Main.cs:17
The program 'Mono' has exited with code 0 (0x0).
Debugging session ended.
The program '[5932] HelloWorld5.vshost.exe: Program Trace' has exited with code 0 (0x0).
The program '[5932] HelloWorld5.vshost.exe' has exited with code 0 (0x0).
我正在使用STABLE版本的Xamarin软件。 请在此处找到示例项目: https://dl.dropboxusercontent.com/u/19503836/PCLAndAsyncWithXamariniOS.zip