public bool Delete()
        {
            try
            {
                // if a rsaprovider exists, make non persistent, clear it and nullify --> the key is deleted

                if (RsaProvider.IsAssigned())
                {
                    // Delete the key entry in the container.
                    RsaProvider.PersistKeyInCsp = false;

                    // Call Clear to release resources and delete the key from the container.
                    RsaProvider.Clear();

                    RsaProvider = null;

                    return(true);
                }

                return(false);
            }
            catch (CryptographicException e)
            {
                Debug.WriteLine("Encryption: UtilHelper.DeleteKeyFromContainer(...) unable to delete key - " + e.Message);

                return(false);
            }
        }
        protected virtual void Dispose(bool disposing)
        {
            if (!_disposed)
            {
                if (RsaProvider.IsAssigned())
                {
                    RsaProvider.Clear(); // resources vrijgeven.

                    RsaProvider = null;
                }
            }
            _disposed = true;
        }
        private void GetKeyContainer(string containerName)
        {
            // - if this is a clientsize Encryption determine maximum keysize
            // - get the serviceprovider
            // - if the serviceprovider allready exists, with the wrong keysize, delete the serviceprovider
            // - get a new serviceprovider if deleted
            // - if the Encryption is temporary, make sure it is not persistend
            try
            {
                var cp = GetCspParameters(containerName);

                if (!RsaProvider.IsAssigned())
                {
                    try
                    {
                        RsaProvider = new RSACryptoServiceProvider(_maxBytesServer * 8, cp);
                    }
                    catch (CryptographicException e)
                    {
                        if (RsaProvider.IsAssigned())
                        {
                            Delete();
                        }

                        throw new Exception("create: " + e.Message, e);
                    }
                }

                if (_maxBytesServer > 0 && RsaProvider.KeySize != _maxBytesServer * 8)
                {
                    try
                    {
                        try
                        {
                            Delete();
                        }
                        catch (CryptographicException e)
                        {
                            {
                                throw new Exception("delete: " + e.Message, e);
                            }
                        }


                        if (!RsaProvider.IsAssigned())
                        {
                            RsaProvider = new RSACryptoServiceProvider(_maxBytesServer * 8, cp);
                        }
                    }
                    catch (CryptographicException e)
                    {
                        {
                            throw new Exception("replace: " + e.Message, e);
                        }
                    }
                }
            }
            catch (CryptographicException e)
            {
                Debug.WriteLine("Encryption: Utilhelper.GetKeyContainer(...) unexpected exception - " + e.Message);

                throw new Exception("most outer: " + e.Message, e);
            }
        }