<value>The unmanaged Version information is too large to persist.</value>
</data>
<data name="Argument_WaitHandleNameTooLong" xml:space="preserve">
- <value>The name '{0}' can be no more than {1} characters in length.</value>
+ <value>The length of the name exceeds the maximum limit.</value>
</data>
<data name="Argument_WinRTSystemRuntimeType" xml:space="preserve">
<value>Cannot marshal type '{0}' to Windows Runtime. Only 'System.RuntimeType' is supported.</value>
private const uint AccessRights =
(uint)Interop.Kernel32.MAXIMUM_ALLOWED | Interop.Kernel32.SYNCHRONIZE | Interop.Kernel32.MUTEX_MODIFY_STATE;
-#if PLATFORM_UNIX
- // Maximum file name length on tmpfs file system.
- private const int WaitHandleNameMax = 255;
-#endif
-
- private static void VerifyNameForCreate(string name)
- {
-#if PLATFORM_WINDOWS
- if (name != null && (Interop.Kernel32.MAX_PATH < name.Length))
- {
- throw new ArgumentException(SR.Format(SR.Argument_WaitHandleNameTooLong, name, Interop.Kernel32.MAX_PATH), nameof(name));
- }
-#endif
- }
-
private void CreateMutexCore(bool initiallyOwned, string name, out bool createdNew)
{
uint mutexFlags = initiallyOwned ? Interop.Kernel32.CREATE_MUTEX_INITIAL_OWNER : 0;
#if PLATFORM_UNIX
if (errorCode == Interop.Errors.ERROR_FILENAME_EXCED_RANGE)
// On Unix, length validation is done by CoreCLR's PAL after converting to utf-8
- throw new ArgumentException(SR.Format(SR.Argument_WaitHandleNameTooLong, name, WaitHandleNameMax), nameof(name));
+ throw new ArgumentException(SR.Argument_WaitHandleNameTooLong, nameof(name));
#endif
if (errorCode == Interop.Errors.ERROR_INVALID_HANDLE)
throw new WaitHandleCannotBeOpenedException(SR.Format(SR.Threading_WaitHandleCannotBeOpenedException_InvalidHandle, name));
throw new ArgumentException(SR.Argument_EmptyName, nameof(name));
}
- VerifyNameForCreate(name);
result = null;
// To allow users to view & edit the ACL's, call OpenMutex
// with parameters to allow us to view & edit the ACL. This will
if (errorCode == Interop.Errors.ERROR_FILENAME_EXCED_RANGE)
{
// On Unix, length validation is done by CoreCLR's PAL after converting to utf-8
- throw new ArgumentException(SR.Format(SR.Argument_WaitHandleNameTooLong, name, WaitHandleNameMax), nameof(name));
+ throw new ArgumentException(SR.Argument_WaitHandleNameTooLong, nameof(name));
}
#endif
if (Interop.Errors.ERROR_FILE_NOT_FOUND == errorCode || Interop.Errors.ERROR_INVALID_NAME == errorCode)
{
public Mutex(bool initiallyOwned, string name, out bool createdNew)
{
- VerifyNameForCreate(name);
CreateMutexCore(initiallyOwned, name, out createdNew);
}
public Mutex(bool initiallyOwned, string name)
{
- VerifyNameForCreate(name);
CreateMutexCore(initiallyOwned, name, out _);
}
{
#if PLATFORM_UNIX
throw new PlatformNotSupportedException(SR.PlatformNotSupported_NamedSynchronizationPrimitives);
-#else
- if (Interop.Kernel32.MAX_PATH < name.Length)
- {
- throw new ArgumentException(SR.Format(SR.Argument_WaitHandleNameTooLong, name, Interop.Kernel32.MAX_PATH), nameof(name));
- }
#endif
}
{
#if PLATFORM_UNIX
throw new PlatformNotSupportedException(SR.PlatformNotSupported_NamedSynchronizationPrimitives);
-#else
- if (Interop.Kernel32.MAX_PATH < name.Length)
- {
- throw new ArgumentException(SR.Format(SR.Argument_WaitHandleNameTooLong, name, Interop.Kernel32.MAX_PATH), nameof(name));
- }
#endif
}
Win32Native.SECURITY_ATTRIBUTES secAttrs = null;
throw new ArgumentException(SR.Argument_EmptyName, nameof(name));
}
- if (null != name && Interop.Kernel32.MAX_PATH < name.Length)
- {
- throw new ArgumentException(SR.Format(SR.Argument_WaitHandleNameTooLong, name, Interop.Kernel32.MAX_PATH), nameof(name));
- }
-
-
result = null;
-
SafeWaitHandle myHandle = Win32Native.OpenEvent(AccessRights, false, name);
if (myHandle.IsInvalid)
{
#if PLATFORM_UNIX
throw new PlatformNotSupportedException(SR.PlatformNotSupported_NamedSynchronizationPrimitives);
-#else
- if (name.Length > Interop.Kernel32.MAX_PATH)
- throw new ArgumentException(SR.Format(SR.Argument_WaitHandleNameTooLong, name, Interop.Kernel32.MAX_PATH), nameof(name));
#endif
}
throw new ArgumentNullException(nameof(name));
if (name.Length == 0)
throw new ArgumentException(SR.Argument_EmptyName, nameof(name));
- if (name.Length > Interop.Kernel32.MAX_PATH)
- throw new ArgumentException(SR.Format(SR.Argument_WaitHandleNameTooLong, name, Interop.Kernel32.MAX_PATH), nameof(name));
//Pass false to OpenSemaphore to prevent inheritedHandles
SafeWaitHandle myHandle = Win32Native.OpenSemaphore(AccessRights, false, name);