Notice (2018-05-24): bugzilla.xamarin.com is now in
Please join us on
Visual Studio Developer Community and in the
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
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.
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?"
System.Core shows version 126.96.36.199
Version 4.1.7 (build 87)
Installation UUID: 938751df-f7a5-457d-b87b-379763e0ada1
Mono 3.1.2 ((no/71af847)
Package version: 301020000
Apple Developer Tools
Xcode 5.0 (3325.22)
Version: 188.8.131.52 (Business Edition)
Build date: 2013-10-07 12:10:26-0400
Xamarin.Mac: Not Installed
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)
Release ID: 401070087
Git revision: e8d353852416693588e6e53a5c2b2d70e5ddadfb
Build date: 2013-07-18 15:32:11+0000
Xamarin addins: 7a764a450cd980c7942b91f12ac36947f9c6a71f
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
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):
Is there an easy way to find out which PCL profiles support a given class on MSDN?
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()`  works in Portable Class Library projects that target .NET 4.5 + Windows Store Apps.
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.
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\
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.
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.
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.
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.