/// <summary>
 /// Create a new AppContainerProfile.
 /// </summary>
 /// <param name="appcontainer_name">The name of the AppContainer.</param>
 /// <param name="display_name">A display name.</param>
 /// <param name="description">An optional description.</param>
 /// <param name="capabilities">An optional list of capability SIDs.</param>
 /// <param name="throw_on_error">True to throw on error.</param>
 /// <returns>The created AppContainer profile.</returns>
 /// <remarks>If the profile already exists then it'll be opened instead.</remarks>
 public static NtResult <AppContainerProfile> Create(
     string appcontainer_name,
     string display_name,
     string description,
     IEnumerable <Sid> capabilities,
     bool throw_on_error)
 {
     using (var resources = new DisposableList())
     {
         var      caps   = resources.CreateSidAndAttributes(capabilities);
         NtStatus status = Win32NativeMethods.CreateAppContainerProfile(appcontainer_name, display_name, description,
                                                                        caps.Length > 0 ? caps : null, caps.Length, out SafeSidBufferHandle sid);
         if (status == NtObjectUtils.MapDosErrorToStatus(Win32Error.ERROR_ALREADY_EXISTS))
         {
             return(new AppContainerProfile(appcontainer_name).CreateResult());
         }
         resources.AddResource(sid);
         return(status.CreateResult(throw_on_error, () =>
         {
             using (sid)
             {
                 return new AppContainerProfile(appcontainer_name, sid.ToSid(),
                                                capabilities, display_name, description);
             }
         }));
     }
 }