从提供的链接:
“根本原因是 CryptoConfig 不理解 SHA256CryptoServiceProvider。它是作为 .NET 3.5 中绿色位的一部分添加的,并且由于分层限制,红色位(例如 RSACryptoServiceProvider 所在的 mscorlib.dll)不知道关于它的存在...
如果您使用的是 .Net Framework 4.0,则解决方法是修改“machine.config”文件:
%WINDIR%\Microsoft.NET\Framework\v4.0.xxxxx\ CONFIG -> for x86
%WINDIR%\Microsoft.NET\Framework64\v4.0.xxxxx\CONFIG -> for x64
如果您使用的是 .Net Framework 3.5,则解决方法是修改“machine.config”文件:
%WINDIR%\Microsoft.NET\Framework\v2.0.xxxxx\ CONFIG -> for x86
%WINDIR%\Microsoft.NET\Framework64\v2.0.xxxxx\CONFIG -> for x64
这是您需要在“machine.config”文件中创建的条目,以支持 SHA256CryptoServiceProvider、SHA256Cng、SHA384CryptoServiceProvider、SHA384Cng、SHA512CryptoServiceProvider 和 SHA512Cng。
<mscorlib>
<cryptographySettings>
<cryptoNameMapping>
<cryptoClasses>
<cryptoClass SHA256CSP="System.Security.Cryptography.SHA256CryptoServiceProvider, System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<cryptoClass SHA256CNG="System.Security.Cryptography.SHA256Cng, System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<cryptoClass SHA384CSP="System.Security.Cryptography.SHA384CryptoServiceProvider, System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<cryptoClass SHA384CNG="System.Security.Cryptography.SHA384Cng, System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<cryptoClass SHA512CSP="System.Security.Cryptography.SHA512CryptoServiceProvider, System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<cryptoClass SHA512CNG="System.Security.Cryptography.SHA512Cng, System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
</cryptoClasses>
<nameEntry name="SHA256" class="SHA256CSP" />
<nameEntry name="SHA256CryptoServiceProvider" class="SHA256CSP" />
<nameEntry name="System.Security.Cryptography.SHA256CryptoServiceProvider" class="SHA256CSP" />
<nameEntry name="SHA256Next" class="SHA256CNG" />
<nameEntry name="SHA256Cng" class="SHA256CNG" />
<nameEntry name="System.Security.Cryptography.SHA256Cng" class="SHA256CNG" />
<nameEntry name="SHA384" class="SHA384CSP" />
<nameEntry name="SHA384CryptoServiceProvider" class="SHA384CSP" />
<nameEntry name="System.Security.Cryptography.SHA384CryptoServiceProvider" class="SHA384CSP" />
<nameEntry name="SHA384Next" class="SHA384CNG" />
<nameEntry name="SHA384Cng" class="SHA384CNG" />
<nameEntry name="System.Security.Cryptography.SHA384Cng" class="SHA384CNG" />
<nameEntry name="SHA512" class="SHA512CSP" />
<nameEntry name="SHA512CryptoServiceProvider" class="SHA512CSP" />
<nameEntry name="System.Security.Cryptography.SHA512CryptoServiceProvider" class="SHA512CSP" />
<nameEntry name="SHA512Next" class="SHA512CNG" />
<nameEntry name="SHA512Cng" class="SHA512CNG" />
<nameEntry name="System.Security.Cryptography.SHA512Cng" class="SHA512CNG" />
</cryptoNameMapping>
<oidMap>
<oidEntry OID="2.16.840.1.101.3.4.2.1" name="SHA256" />
<oidEntry OID="2.16.840.1.101.3.4.2.1" name="SHA256Next" />
<oidEntry OID="2.16.840.1.101.3.4.2.2" name="SHA384" />
<oidEntry OID="2.16.840.1.101.3.4.2.2" name="SHA384Next" />
<oidEntry OID="2.16.840.1.101.3.4.2.3" name="SHA512" />
<oidEntry OID="2.16.840.1.101.3.4.2.3" name="SHA512Next" />
</oidMap>
</cryptographySettings>
</mscorlib>
链接:http: //blogs.msdn.com/b/winsdk/archive/2010/08/18/getting-a-system-argumentexception-value-was-invalid-when-trying-to-sign-data-using- sha256cryptoserviceprovider.aspx