从iPhone客户端进行调用时System.PlatformNotSupportedException

时间:2013-07-25 04:38:00

标签: visual-studio xamarin xamarin.ios task-parallel-library portable-class-library

我尝试使用MonoTouch在Visual Studio 2012下运行任务。我正在使用ALPHA频道并安装了最新版本。

解决方案中有3个项目: 1.具有异步方法的PCL(158个目标平台) 2.触摸 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).

1 个答案:

答案 0 :(得分:3)

有点迟到的回复,但万一有人还在讨论这个问题,看起来有一种解决方法是在“项目选项 - &gt; iOS构建 - &gt;其他mtouch参数”下添加--nolinkaway --linkskip=mscorlib主要的应用项目。

如果没有这个,链接器会删除Microsoft.Bcl包进行兼容性检查所需的mscorlib内容。

此处提交的错误:https://bugzilla.xamarin.com/show_bug.cgi?id=15290