Xamarin Studio Mac, Portable class library, Async and Android

浪子不回头ぞ 提交于 2019-12-18 18:38:05

问题


Edit: On the Alpha Channel Profile7, Profile49 and Profile78 seem to work. I'm working with the setup that was described here: Getting PCL, Mvvmcross, Nuget and Xamarin Studio to play "nice" on Mac .

How do you make a PCL in Xamarin Studio with Async support work.

I'm usually using Profile104 which is TargetFrameworkVersion v4.0

I tried the following combinations of the hree different v4.5 profiles Profile7, Profile49, Profile78 with the different versions of Xamarin Studio:

                              Profile7     Profile 49    Profile 78
Alpha (4.1.10, mono=3.2.2)     1            1             1
Beta (4.0.12, mono=3.2.1)      2            2             2
Stable (4.0.12, mono=3.2.0)    1            1             1
  1. System.Type, System.Threading not found. Unusable
  2. Profile not found: /Library/Frameworks/Mono.framework/Versions/3.2.1/lib/mono/xbuild/Microsoft/Portable/v4.5/Microsoft.Portable.CSharp.targets is missing

Basically none of the 4.5 profiles is working in any of the currently available Xamarin Studio versions for Mac.


回答1:


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.



来源:https://stackoverflow.com/questions/18788437/xamarin-studio-mac-portable-class-library-async-and-android

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