调用此时:
Check(NativeMethods.CryptAcquireContextW(
out providerContext,
containerName,
null,
1, // PROV_RSA_FULL
8)); // CRYPT_NEWKEYSET
我得到这个:
系统找不到指定的文件。(HRESULT出现异常:0x80070002):堆栈跟踪:位于System.Runtime.InteropServices.Marshal.SthrowExceptionForHRInternal(Int32错误代码,IntPtr错误信息)在System.Runtime.InteropServices.Marshal.SthrowExceptionForHR(Int32错误代码)
似乎与此相似http://social.msdn.microsoft.com/Forums/en-US/wcf/thread/feaf03f7-51a8-48d6-825f-e04c4ff2ef3a
我在web应用程序中执行此操作时遇到了此问题。对我来说,解决方案是将应用程序池标识从ApplicationPoolIdentity更改为NetworkService(应用程序池的高级设置)。在Windows 2008 Server R2上运行IIS7。