Bug 26067 - Mutexes cannot be created with names without resulting in error
Summary: Mutexes cannot be created with names without resulting in error
Status: RESOLVED FEATURE
Alias: None
Product: Android
Classification: Xamarin
Component: BCL Class Libraries (show other bugs)
Version: 4.20.0
Hardware: PC Mac OS
: Normal normal
Target Milestone: ---
Assignee: Jonathan Pryor
URL:
Depends on:
Blocks:
 
Reported: 2015-01-15 09:56 UTC by Allie Miller
Modified: 2018-03-28 21:27 UTC (History)
4 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 Developer Community or GitHub 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 FEATURE

Description Allie Miller 2015-01-15 09:56:43 UTC
Overview
In a PCL project, using mutexes in both the Android and iOS projects result in different behaviors. While the iOS project deploys fine during a release deployment (as this only has one process), the Android project fails with the following error: 

InnerException was NotSupportedException: Operation is not supported.
01-14 14:23:49.310: I/mono-stdout(11785): at System.Threading.Mutex..ctor (Boolean initiallyOwned, System.String name) [0x00000] in <filename unknown>:0
01-14 14:23:49.310: I/mono-stdout(11785): at (wrapper remoting-invoke-with-check) System.Threading.Mutex:.ctor (bool,string)

Steps to reproduce issue
1) Using the attached sample application, please set the following configuration in Xamarin Studio under the project options->Android build settings:
**General tab**
 a) Release configuration
 b) Embed assembies in native code
**Linker tab**
 c) Link SDK assembilies only
**Advanced tab**
 d) Supported ABIs: armeabi-v7a
 e) Java Heap Size: 1G
**Under Android Application settings**
 f) Ensure that the minimum Android version is set to API 16 and target is API 21
2) Attempt to deploy to device

Expected result
Application deploys to device and runs with no issue

Actual result
Application fails to successfully run and errors out with above message

Additional information
This does not occur during a debug deployment when the Mono Shared Runtime is enabled along with Fast Assembly Deployment.

Versioning Information
=== Xamarin Studio ===

Version 5.7 (build 661)
Installation UUID: f6a3c61f-a7e2-4740-ba09-86314760e340
Runtime:
	Mono 3.12.0 ((detached/a813491)
	GTK+ 2.24.23 (Raleigh theme)

	Package version: 312000068

=== Apple Developer Tools ===

Xcode 6.1.1 (6611)
Build 6A2008a

=== Xamarin.Mac ===

Version: 1.10.0.18 (Enterprise Edition)

=== Xamarin.iOS ===

Version: 8.6.0.51 (Enterprise Edition)
Hash: dfb682f
Branch: 
Build date: 2015-01-08 13:39:32-0500

=== Xamarin.Android ===

Version: 4.20.0.28 (Enterprise Edition)
Android SDK: /Users/XXX/Library/Developer/Xamarin/android-sdk-macosx
	Supported Android versions:
		1.6    (API level 4)
		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)
		4.2    (API level 17)
		4.3    (API level 18)
		4.4    (API level 19)
		4.4.87 (API level 20)
		5.0    (API level 21)
Java SDK: /usr
java version "1.7.0_71"
Java(TM) SE Runtime Environment (build 1.7.0_71-b14)
Java HotSpot(TM) 64-Bit Server VM (build 24.71-b01, mixed mode)

=== Build Information ===

Release ID: 507000661
Git revision: b70bab61da996da29045ea8ee8aed1a6faedbe78
Build date: 2015-01-05 16:31:31-05
Xamarin addins: 82f6c71490562d6cd125a09287f441902fdac3d7

=== Operating System ===

Mac OS X 10.10.1
Darwin XXX-MacBook-Air.local 14.0.0 Darwin Kernel Version 14.0.0
    Fri Sep 19 00:26:44 PDT 2014
    root:xnu-2782.1.97~2/RELEASE_X86_64 x86_64
Comment 3 Jonathan Pryor 2015-01-15 15:22:40 UTC
The MOBILE profile does not support named mutexes: 

https://github.com/mono/mono/blob/988f522b3/mcs/class/corlib/System.Threading/Mutex.cs#L167

iOS should throw as well, if that method is invoked. However:

> While the iOS project deploys fine during a release deployment

Deployment != execution, and the exception would only be thrown if the app is executed on-device; Comment #0 doesn't state anything about execution behavior on iOS.
Comment 4 Luis Roquette Valdez 2017-01-18 10:09:12 UTC
Just to ask, WHY isn't is supported?
Code for that can easily be produced.
Comment 5 Xavier Rigau 2018-03-28 21:27:52 UTC
Thanks! That broke my porting from Xamarin.Full ro Xamarin.Mobile! WHY is not supported?