Bug 13409 - PCL System.Core does not contain ReaderWriteLockSlim
Summary: PCL System.Core does not contain ReaderWriteLockSlim
Status: RESOLVED FIXED
Alias: None
Product: Class Libraries
Classification: Mono
Component: System.Core ()
Version: unspecified
Hardware: Macintosh Mac OS
: --- normal
Target Milestone: Untriaged
Assignee: Martin Baulig
URL:
Depends on:
Blocks:
 
Reported: 2013-07-23 10:15 UTC by kissling
Modified: 2013-09-16 13:24 UTC (History)
3 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on GitHub or Developer Community with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED FIXED

Description kissling 2013-07-23 10:15:00 UTC
In PCL library projects, the System.Core.dll does not contain the type "ReaderWriterLockSlim" (http://msdn.microsoft.com/en-us/library/system.threading.readerwriterlockslim.aspx), although it is listed as supported on the MSDN page.

When compiling code that references System.dll, and System.Core.dll, then using ReaderWriterLockSlim, a compiler error is shown: "The type or namespace name `ReaderWriterLockSlim' could not be found. Are you missing an assembly reference?"



Version information:

System.Core shows version 2.0.5.0

Xamarin Studio
Version 4.1.7 (build 87)
Installation UUID: 938751df-f7a5-457d-b87b-379763e0ada1
Runtime:
	Mono 3.1.2 ((no/71af847)
	GTK 2.24.20
	GTK# (2.12.0.0)
	Package version: 301020000

Apple Developer Tools
Xcode 5.0 (3325.22)
Build 5A11344j

Xamarin.iOS
Version: 6.9.4.40 (Business Edition)
Hash: 7f9e851
Branch: 
Build date: 2013-10-07 12:10:26-0400

Xamarin.Mac
Xamarin.Mac: Not Installed

Xamarin.Android
Version: 4.8.0 (Business Edition)
Android SDK: /Users/***/Library/Developer/Xamarin/android-sdk-mac_x86
	Supported Android versions:
		2.1   (API level 7)
		2.2   (API level 8)
		2.3   (API level 10)
		3.1   (API level 12)
		4.0   (API level 14)
		4.0.3 (API level 15)
Java SDK: /usr
java version "1.6.0_51"
Java(TM) SE Runtime Environment (build 1.6.0_51-b11-457-11M4509)
Java HotSpot(TM) 64-Bit Server VM (build 20.51-b01-457, mixed mode)

Build Information
Release ID: 401070087
Git revision: e8d353852416693588e6e53a5c2b2d70e5ddadfb
Build date: 2013-07-18 15:32:11+0000
Xamarin addins: 7a764a450cd980c7942b91f12ac36947f9c6a71f

Operating System
Mac OS X 10.8.4
Darwin ***.local 12.4.0 Darwin Kernel Version 12.4.0
    Wed May  1 17:57:12 PDT 2013
    root:xnu-2050.24.15~1/RELEASE_X86_64 x86_64
Comment 1 Brendan Zagaeski (Xamarin Team, assistant) 2013-08-21 16:36:39 UTC
Just came across this bug report after I saw the same error on another case. I suspect the absence of `ReaderWriterLockSlim` is not a bug, but instead a consequence of the selected platforms (the PCL profile):
http://social.msdn.microsoft.com/Forums/vstudio/en-US/bdfe44d9-229f-4ce6-96a4-bc6c0d084c55/readerwriterlockslim-class-missing-from-portable-class-library-subset
Comment 2 kissling 2013-08-21 17:38:22 UTC
Seems true.

Is there an easy way to find out which PCL profiles support a given class on MSDN?
Comment 3 Brendan Zagaeski (Xamarin Team, assistant) 2013-08-21 19:09:09 UTC
The "Version Information" section near the bottoms of the pages seems to be the best place to look. If the class is supported in all of the target platforms and also in "Portable Class Library", then it will work.

One additional complication is that when targeting .NET 4.5 profiles, such as .NET 4.5 + Windows Store Apps, "Supported in: Portable Class Library" is *not* required. For example, `Task.Run()` [1] works in Portable Class Library projects that target  .NET 4.5 + Windows Store Apps.

[1] http://msdn.microsoft.com/en-us/library/hh195051.aspx
Comment 4 kissling 2013-08-26 05:29:02 UTC
The problem is that although ReaderWriterLockSlim is tagged as being supported in .NET 4.5, it doesn't become available even after disabling all other platforms.

Note that even when disabling Xamarin.Android and Xamarin.iOS, they always get reenabled by default.

However, when targetting Xamarin.Android and Xamarin.iOS directly with an Android or iOS library project, ReaderWriterLockSlim is available.
Comment 5 Brendan Zagaeski (Xamarin Team, assistant) 2013-08-26 18:26:02 UTC
It's likely that the only place you currently have copies of the Xamarin.Android and Xamarin.iOS XML definition files is in:
`Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETPortable\v4.0\Profile\
Profile104\SupportedFrameworks`

Now that Xamarin supports full .NET 4.5, you'll want to add these XML files to the various `SupportedFrameworks` directories in `v4.5`:
`Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETPortable\v4.5\`

For the moment, the .NET 4.5 profiles are limited to combinations of .NET 4.5, Windows Phone 8, and .NET for Windows Store Apps. Creating a PCL project requires selecting at least 2 of these targets. This means that currently there is no PCL profile that has 100% coverage of .NET 4.5. That said, the ".NET 4.5 + Windows Store" profile is relatively featureful.

Note that presently *all* PCL profiles will work with Xamarin.Android and Xamarin.iOS. Adding the Xamarin XML files to `SupportedFrameworks` just lets the Visual Studio IDE know that it's OK for Xamarin.iOS and Xamarin.Android projects to reference PCL projects that use the various profiles.
Comment 6 Martin Baulig 2013-09-16 04:46:26 UTC
ReaderWriterLockSlim is in PCLv1 profiles Profile5 (.NET 4 + WinStore), Profile6 (.NET 4.0.3 + WinStore) and all PCLv2 profiles (Profile7, Profile49, Profile78).

For PCLv2, select .NET 4.5 and WinStore (Profile7); add WP8 for Profile8 and Profile49 is .NET 4.5 + WP8.
Comment 7 kissling 2013-09-16 04:49:21 UTC
Thanks! The problem seems to be Xamarin Studio related. While Visual Studio supports ReaderWriteLockSlim and similar classes / methods properly for PCLs, they don't work under Xamarin Studio.
Comment 8 Mikayla Hutchinson [MSFT] 2013-09-16 13:24:59 UTC
Mono does not currently includes PCL reference assemblies. Until it does, Xamarin Studio transparently uses some other assemblies for building PCL projects, most likely the Xamarin.iOS assemblies. This is why the assemblies you're looking at don't exactly match the actual PCL assemblies.