2

.Net 4.0/4.5 を使用して、整合性レベルが低い Windows 8 x64 のデスクトップ アプリケーションで名前付きセマフォを作成/開こうとしています。

同じコードは Windows 7 x64 では機能しますが、Windows 8 Entreprise x64 では System.IO.IOException: "A required privileges is not hold by the client" で失敗します。

コードは次のとおりです (コンソール アプリケーション)。

class Program
{
   static void Main(string[] args)
   {
      System.Security.AccessControl.SemaphoreSecurity sec = null;

      //[low integrity level[
      sec = new System.Security.AccessControl.SemaphoreSecurity();
      sec.SetSecurityDescriptorSddlForm("S:(ML;;NW;;;LW)");
      //]low integrity level]

      try
      {
         bool createdNew;
         var sem = new System.Threading.Semaphore(0, int.MaxValue, "MySemaphoreName", out createdNew, sec);
         if (createdNew) { Console.WriteLine("Semaphore created"); }
         else            { Console.WriteLine("Semaphore opened"); }
      }
      catch (Exception ex)
      {
         Console.WriteLine("Exception occured {0}", ex);
      }
      ConsoleKeyInfo cki = Console.ReadKey();
   }
}

次のブロックを削除すると、両方のシステムで機能します。

sec = new System.Security.AccessControl.SemaphoreSecurity();
sec.SetSecurityDescriptorSddlForm("S:(ML;;NW;;;LW)");

どんな助けでも大歓迎です。

4

0 に答える 0