完全にランダムな例外が発生しています。同じコードセットを1000回実行して(各「実行」はプログラムの完全なエンドエンドであるため、コマンドラインから独自のプロセスとして開始されてから存在します)、取得できます。 1回、または150回も失敗します。そして、私はそれを何度も何度も実行することができ、それは完全にランダムに失敗することを意味します。
System.Security.AccessControl.PrivilegeNotHeldException: The process does not possess the 'SeSecurityPrivilege' privilege which is required for this operation.
at System.Security.AccessControl.Win32.GetSecurityInfo(ResourceType resourceType, String name, SafeHandle handle, AccessControlSections accessControlSections, RawSecurityDescriptor& resultSd)
at System.Security.AccessControl.NativeObjectSecurity.CreateInternal(ResourceType resourceType, Boolean isContainer, String name, SafeHandle handle, AccessControlSections includeSections, Boolean createByName, ExceptionFromErrorCode exceptionFromErrorCode, Object exceptionContext)
at System.Security.AccessControl.RegistrySecurity..ctor(SafeRegistryHandle hKey, String name, AccessControlSections includeSections)
at Microsoft.Win32.RegistryKey.GetAccessControl(AccessControlSections includeSections)
デバッグ時に失敗させることができないので、ランダムに失敗することを決定する理由を確認しようとして問題が発生しています。メソッド内で失敗した(RegistryKey).GetAccessControl(AccessControlSections.All)
ため、次に何を試すべきかについて困惑しています。
また、私は複数のキーをループしていますが、1つのキーでこのアクセス許可の例外が発生して失敗すると判断した場合、それらはすべてそのプロセスで失敗します。
私はコマンドラインから(管理者として、UACで)実行しており、プロセスを開始すると、それが存在します。同じコマンドラインからプロセスを再開すると、ランダムに失敗します。
ユーザーハイブをロードし、レジストリ権限が昇格されていることを確認しています。これは、このランダムなバグを除いて機能します。
また、この問題は、システム(psexec)アカウントと管理者アカウントの両方で、複数のマシン(リモートではなく、常にローカルで実行されている)で発生します。