10

Looking at http://msdn.microsoft.com/en-us/library/dd287191(v=vs.110).aspx, it seems that ConcurrentDictionary and all of its friends in the System.Collections.Concurrent namespace are available for use in a Portable Class Library.

However, when I create either an F# or C# Portable Class Library, even if I explicitly add a reference to mscorlib.dll, the compilation fails when using ConcurrentDictionary.

Why?

svick
  • 236,525
  • 50
  • 385
  • 514
Okay
  • 224
  • 1
  • 9

1 Answers1

10

The term "Portable" should be loosely applied right now. When you create the class library project, you get prompted for the targets you want to support. You'll only get ConcurrentDictionary when you select ".NET Framework" and ".NET for Windows Store apps".

Pick any other and the entire namespace disappears.

This will get better over time, I'd assume, but Windows Phone 7, XBox and Silverlight are lagging behind right now.

Hans Passant
  • 922,412
  • 146
  • 1,693
  • 2,536
  • 1
    You were right, but I only get the prompt with **C# Projects**. By deactivating all except the two you told me, I could use this namespace :). The **F# Portable Class Library** project template doesn't prompt me these options though :(. – Okay Aug 30 '12 at 18:40
  • 2
    I repro that. F# is further constrained (no XBox or Phone) and has a fixed subset. Which includes Silverlight so that's a no-go there. – Hans Passant Aug 30 '12 at 18:49
  • 2
    Yes, unfortunately, F# only supports a fixed subset of platforms via portable; Silverlight 5, .NET Framework 4.5 and Windows Store apps. – David Kean Sep 12 '12 at 21:15
  • 1
    Maybe this one can help you : https://www.nuget.org/packages/Portable.ConcurrentDictionary – Stef Heyenrath Nov 12 '16 at 10:18