7
public RSAKeyPair()
{
string keyContainerName="pEncKey"
CspParameters cspp = new CspParameters();
cspp.Flags = CspProviderFlags.UseMachineKeyStore;
cspp.KeyContainerName = keyContainerName;
try
{
m_RSA = new RSACryptoServiceProvider(1024, cspp);
}
catch(Exception e){}
}
什么是抛出下列异常的原因:System.Security.Cryptography.CryptographicException -object已经存在
System.Security.Cryptography.CryptographicException - object already exist
堆栈跟踪如下:
at System.Security.Cryptography.CryptographicException.ThrowCryptographicException(Int32 hr)
at System.Security.Cryptography.Utils._CreateCSP(CspParameters param, Boolean randomKeyContainer, SafeProvHandle& hProv)
at System.Security.Cryptography.Utils.CreateProvHandle(CspParameters parameters, Boolean randomKeyContainer)
at System.Security.Cryptography.Utils.GetKeyPairHelper(CspAlgorithmType keyType, CspParameters parameters, Boolean randomKeyContainer, Int32 dwKeySize, SafeProvHandle& safeProvHandle, SafeKeyHandle& safeKeyHandle)
at System.Security.Cryptography.RSACryptoServiceProvider.GetKeyPair()
at System.Security.Cryptography.RSACryptoServiceProvider..ctor(Int32 dwKeySize, CspParameters parameters, Boolean useDefaultKeySize)
at System.Security.Cryptography.RSACryptoServiceProvider..ctor(Int32 dwKeySize, CspParameters parameters)
at XXXXXXXX.Core.RSAKeyPair..ctor(String keyContainerName)
快速谷歌把这个了:http://pwnedcode.wordpress.com/2008/11/10/fixing-cryptographicexception-%E2%80 %9Cobject-已经存在%E2%80%9D /。你有没有尝试修复访问密钥容器? – 2012-07-11 17:19:37
@owlstead这是为asp.net命令行之一。 :( – DevT 2012-07-12 03:38:20