Skip to content

System.ArgumentNullException on new MutexAccessRule #111060

@adamcalvet

Description

@adamcalvet

Description

Since the last System.Threading.AccessControl package update from version 8.0.0 to 9.0.0, trying to run the MutexAccessRule ctor gives a System.ArgumentNullException: 'Value cannot be null. (Parameter 'identity')'
Returning to version 8.0.0 "corrects" the problem.

Reproduction Steps

I have a "single application instance" detection function, using the "classic" Mutex approach:

var identity = new SecurityIdentifier(WellKnownSidType.WorldSid, null);
var allowEveryoneRule = new MutexAccessRule(identity, MutexRights.FullControl, AccessControlType.Allow);  // <-- Exception here!
var securitySettings = new MutexSecurity();
securitySettings.AddAccessRule(allowEveryoneRule);
var mutex = new Mutex(true, __MUTEX_ID, out createdNew);
mutex.SetAccessControl(securitySettings);

Expected behavior

This line:
var allowEveryoneRule = new MutexAccessRule(identity, MutexRights.FullControl, AccessControlType.Allow);
should create a new MutexAccessRule instance. On package version 8.0.0, it correctly does.

Actual behavior

This line:
var allowEveryoneRule = new MutexAccessRule(identity, MutexRights.FullControl, AccessControlType.Allow);
throws
System.ArgumentNullException: 'Value cannot be null. (Parameter 'identity')'
on package version 9.0.0.

Regression?

Package version 9.0.0 fails. Version 8.0.0 works.

Known Workarounds

No response

Configuration

  • NET Version: net6.0-windows

My desktop computer:

  • Windows 10 Pro, version 22H2 (19045.5247)
  • x64 Intel Core i5

Also the same behaviour on the server machine:

  • Windows 10 Pro, version 22H2 (19045.3930)
  • x64 Intel Xeon E5

Other information

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions