问题
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
- System.Type, System.Threading not found. Unusable
- 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.
Set your PCL-Project to 4.0 Profile 104, in your csproj the lines are:
<TargetFrameworkProfile>Profile104</TargetFrameworkProfile> <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
On your PCL-Project, "Manage Nuget packages", search for Async, Add the package with the ID: Microsoft.Bcl.Async
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.
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