C# &引用;System.Security.Cryptography.CryptographyException:发生内部错误“;?

C# &引用;System.Security.Cryptography.CryptographyException:发生内部错误“;?,c#,saml,acs,x509certificate2,C#,Saml,Acs,X509certificate2,在我的项目中,我使用ACS SAML安全性。这里我们需要提供客户端证书和服务器私钥来调用服务,这些可以在webconfig文件中设置。在Azure中运行的web服务很好,但我需要在远程服务器中运行web服务。所以我在IIS中发布了这个项目。但我有个例外 发生内部错误 描述:执行当前web请求期间发生未处理的异常。请查看堆栈跟踪以了解有关错误的更多信息以及错误在代码中的起源 异常详细信息:System.Security.Cryptography.CryptographyException:发生内部

在我的项目中,我使用ACS SAML安全性。这里我们需要提供客户端证书和服务器私钥来调用服务,这些可以在webconfig文件中设置。在Azure中运行的web服务很好,但我需要在远程服务器中运行web服务。所以我在IIS中发布了这个项目。但我有个例外

发生内部错误

描述:执行当前web请求期间发生未处理的异常。请查看堆栈跟踪以了解有关错误的更多信息以及错误在代码中的起源

异常详细信息:System.Security.Cryptography.CryptographyException:发生内部错误

源错误:

在执行当前web请求期间生成了未经处理的异常。有关异常的起源和位置的信息可以使用下面的异常堆栈跟踪来识别

堆栈跟踪:


因此,请帮助我..如何解决此问题?

如果没有引发此异常的代码,我将无能为力。Acs SAML安全服务已在Azure上成功运行。。但我也需要在IIS中工作。所以我想更改IIS服务器设置中的任何内容?例如,帐户可能缺少某些权限?如果您编写的代码中没有出现这种情况,则说明您在错误的位置发布。如果它是在您编写的代码中,您需要发布一些源代码,以便任何人都能提供帮助。由于编译期间出现异常,无法激活服务“/ICMDMMultiWebService/CMDMCustomerWebService.svc”…您使用的IIS版本是什么?您是否允许应用程序池标识访问证书存储中的证书?或者,如果是物理路径,请确保应用程序池标识有足够的权限读取证书文件。
[CryptographicException: An internal error occurred.]
   System.Security.Cryptography.CryptographicException.ThrowCryptographicException(Int32 hr) +41
   System.Security.Cryptography.X509Certificates.X509Utils._LoadCertFromFile(String fileName, IntPtr password, UInt32 dwFlags, Boolean persistKeySet, SafeCertContextHandle& pCertCtx) +0
   System.Security.Cryptography.X509Certificates.X509Certificate.LoadCertificateFromFile(String fileName, Object password, X509KeyStorageFlags keyStorageFlags) +372
   System.Security.Cryptography.X509Certificates.X509Certificate2..ctor(String fileName, String password) +157
   ClassicMDM.WCFServiceWebRole.MyServiceHostfactory.GetServiceCertificateWithPrivateKey() in F:\Core\_Core\Class\trunk\test.WCFServiceWebRole\testWebService.svc.cs:172
   test.WCFServiceWebRole.MyServiceHostfactory.CreateServiceHost(Type serviceType, Uri[] baseAddresses) in F:\Core\_Core\Class\trunk\test.WCFServiceWebRole\testWebService.svc.cs:140
   System.ServiceModel.Activation.ServiceHostFactory.CreateServiceHost(String constructorString, Uri[] baseAddresses) +530
   System.ServiceModel.HostingManager.CreateService(String normalizedVirtualPath) +1413
   System.ServiceModel.HostingManager.ActivateService(String normalizedVirtualPath) +50
   System.ServiceModel.HostingManager.EnsureServiceAvailable(String normalizedVirtualPath) +1172

[ServiceActivationException: The service '/testwebserviceINT/testWebService.svc' cannot be activated due to an exception during compilation.  The exception message is: An internal error occurred]
   System.Runtime.AsyncResult.End(IAsyncResult result) +901424
   System.ServiceModel.Activation.HostedHttpRequestAsyncResult.End(IAsyncResult result) +178702
   System.Web.CallHandlerExecutionStep.OnAsyncHandlerCompletion(IAsyncResult ar) +136