Forum Xamarin Cross Platform with Xamarin

PCL - using System.Threading.Tasks.Task and System.Collections.Generic.HashSet<T>


I am trying to create a Portable Class Library that will be used in an Android project and make use of System.Threading.Tasks.Task and System.Collections.Generic.HashSet. Both classes are included in .NET portable profile and my code compiles. However when I add Mono for Android as one of the target frameworks for my PCL the classes become unavailable.

Given that you have implemented these what is the right way to bring these into a PCL that can be referenced from an Android application? It might be related to the earlier thread for HttpClient and I am looking for some strategic guidance that does not involve rebuilding mono sources as PCLs - is it possible?

Thanks for your help

Best Answer


  • govisgovis USMember

    After going through some other threads It seems that one of the options is not to include Mono in Target frameworks and reference the PCL assembly as a dll as opposed to a project reference.

  • govisgovis USMember

    Thanks for your help and suggestions. I am on Windows/VS2012. I did try selecting .NET 4.5 and .NET for Windows store Apps. The issues I ran into there were I think related to some API changes in .NET 4.5 and even though Task and HashSet did show up, a bunch of other functionality became unavailable. For example System.Type and some related functionality such as System.Reflection.BindingFlags and Type.GetFields(BindingFlags) became unavailable along with System.ServiceModel.Dispatcher.ClientRuntime that had a number of Client* members added to it and some of the old members such as MessageInspectors became unavailable.

    It looks that Mono code base that I have is based on the 4.0 API so I was wondering if there is a version that reflects 4.5 API changes?

    What I also noticed was that there seems to be a large subset of API that has "Supported in: Portable Class Library" flag but not the ".NET for Windows Store apps" for some reason.


  • govisgovis USMember

    And you are right, after taking a closer look on MSDN - Task and HashSet seem to have acquired PCL support in .NET version 4.5. Thanks for pointing that out.

Sign In or Register to comment.