public SafeProvHandleImpl(IntPtr handle, bool addref)
            : base(true)
        {
            if (!addref)
            {
                SetHandle(handle);
            }
            else
            {
                bool success;
                int  errorCode;

                // Обеспечивает атомарность блока finally
                RuntimeHelpers.PrepareConstrainedRegions();
                try { }
                finally
                {
                    success   = CryptoApi.CryptContextAddRef(handle, null, 0);
                    errorCode = Marshal.GetLastWin32Error();

                    if (success)
                    {
                        SetHandle(handle);
                    }
                }

                if (!success)
                {
                    throw ExceptionUtility.CryptographicException(errorCode);
                }
            }
        }