Xamarin Studio Mac, Portable class library, Async and Android

与世无争的帅哥 提交于 2019-11-30 16:39:41

Edit: These instructions apply to the Stable Channel. On the Alpha channel you can use Profile 158, v4.0 which works fine with async.

The following setup seems to work with Android, haven't tried with Touch.

  1. Set your PCL-Project to 4.0 Profile 104, in your csproj the lines are:

    <TargetFrameworkProfile>Profile104</TargetFrameworkProfile>
    <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
    
  2. On your PCL-Project, "Manage Nuget packages", search for Async, Add the package with the ID: Microsoft.Bcl.Async

  3. Your async code should now compile in the PCL, however the Android project will complain about missing dlls and you can't (or maybe shouldn't) add the Async Targeting Pack to it.

  4. On the Android project, Options, Build/Android Build, on the Linker tab, add the following to "Ignore assemblies": System.Threading.Tasks.dll;Microsoft.Threading.Tasks.dll;Microsoft.Threading.Tasks.Extensions.dll. My csproj contains the following lines:

    <AndroidLinkSkip>System.Threading.Tasks.dll;Microsoft.Threading.Tasks.dll;Microsoft.Threading.Tasks.Extensions.dll</AndroidLinkSkip>
    

You might need to restart Xamarin Studio, on my machine the "Ignore assemblies" didn't work immediately on one of the Droid test projects.

Your Android project should now build and deploy with async support in a PCL dependency.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!