为什么同样的程序,放在服务器上就抛错误

为什么同样的程序,放在服务器上就抛异常?


如题,服务器08系统,.net 4.0,有哪些原因可能出现这种问题?

Unhandled Exception: System.Security.Cryptography.CryptographicException: 不正确
的数据。
   at System.Security.Cryptography.CryptographicException.ThrowCryptographicExce
ption(Int32 hr)
   at System.Security.Cryptography.Utils._DecryptData(SafeKeyHandle hKey, Byte[]
 data, Int32 ib, Int32 cb, Byte[]& outputBuffer, Int32 outputOffset, PaddingMode
 PaddingMode, Boolean fDone)
   at System.Security.Cryptography.CryptoAPITransform.TransformFinalBlock(Byte[]
 inputBuffer, Int32 inputOffset, Int32 inputCount)
   at System.Security.Cryptography.CryptoStream.FlushFinalBlock()
   at System.Security.Cryptography.CryptoStream.Dispose(Boolean disposing)
   at System.IO.Stream.Close()
   at System.IO.StreamReader.Dispose(Boolean disposing)
   at EncryptDecrypt.DESEncrypt.DecryptCore(Byte[] CypherText, SymmetricAlgorith
m key)
   at EncryptDecrypt.DESEncrypt.Decrypt(String hex_text, String _key)
   at EncryptDecrypt.DESEncrypt.Decrypt(String hex_text)

出问题的地方就是一个加密解密函数,但是本地都没问题,想半天没想通。。。
------解决思路----------------------
注意检查代码中是否存在变量名称的字符一样,仅以大小写进行了区分,有则改掉。
------解决思路----------------------
还有一点,服务器的C:\Documents and Settings\All Users\Application Data\Microsoft\Crypto\RSA\MachineKeys 目录文件夹重设一下权限再试试看:
administrators:完全
network service: 读\写
------解决思路----------------------
引用:
Quote: 引用:

注意检查代码中是否存在变量名称的字符一样,仅以大小写进行了区分,有则改掉。


引用:
还有一点,服务器的C:\Documents and Settings\All Users\Application Data\Microsoft\Crypto\RSA\MachineKeys 目录文件夹重设一下权限再试试看:
administrators:完全
network service: 读\写

谢谢,找到问题了,本地32位和服务器64位加密同一个字符串得到的密文居然不一样,晕,所以用64位的环境解密32位的密文就报错了,看来还得完善程序

程序编译成x86试试
------解决思路----------------------
这就跟int在32位里是表示Int32,在64位下其实是Int64一样
你把程序编译成x86,应该就一致了