3

セマフォを作成しています:

System.Security.Principal.SecurityIdentifier sid = new System.Security.Principal.SecurityIdentifier(System.Security.Principal.WellKnownSidType.WorldSid, null);
try
{
    bool createdNew;
    System.Security.AccessControl.SemaphoreSecurity semaphoreSecurity = new System.Security.AccessControl.SemaphoreSecurity();
    semaphoreSecurity.SetAccessRule(new System.Security.AccessControl.SemaphoreAccessRule(sid, System.Security.AccessControl.SemaphoreRights.FullControl, System.Security.AccessControl.AccessControlType.Allow));
    this.semaphore = new Semaphore(1, 1, semaphoreName, out createdNew, semaphoreSecurity);
    if (!this.semaphore.WaitOne(timeoutInMilliSeconds))
        throw new TimeoutException("Timeout while waiting " + semaphoreName + " semaphore (" + timeoutInMilliSeconds + " ms)");
}
catch (System.UnauthorizedAccessException e)
{
    this.semaphore = null;
    throw new UnauthorizedAccessException("Semaphore '" + semaphoreName + "'. " + e.Message);
}
catch
{
    this.semaphore = null;
    throw;
}

そして、次のメッセージを含む Semaphore コンストラクターに UnauthorizedAccessException があります。

セマフォ 'Global\Program.Req.Sem'. ポートへのアクセスが拒否されました」

どうしたの?修正方法は?

追加情報:「管理者」グループのメンバーであっても、管理者以外のユーザーにのみ発生すると思います。

4

0 に答える 0