I have a web service that creates an instance of the System.Security.Cryptograp
class. When I deploy this service to an IIS6.0 server and execute it under an app pool whose identity is set to a machine specific user (which was added to the IIS_WPG group), I cannot execute the method ToXMLString(). I am getting a "The system cannot find the file specified" error.
When I point my test project's web reference to the web service in my VS 2008 solution, I have no problems. When I point my test project's web reference to the web service deployed on my local machine's IIS 5.1, again I have no problems.
I suspect a permissions issue is the most likely cause. However, I cannot determine where or why a file is attempting to be referenced when I call the ToXMLString() method - so I don't know what, if any, permissions need to be modified.
I am not persisting the keys into a KeyContainer - I simply generate a random key pair (by instantiating the RSACryptoProvider class) and then am trying to save the Public Key into a local variable. In addition, when I examine the CspKeyContainerInfo class at run time after the RSACryptoProvider object has been created, nothing seems unusual (for example, Accessible = true, Exportable = true, MachineKeyStore = false ).
Any advice would be much appreciated.
public class RSAProvider : AsymmetricBase
private RSACryptoServiceProvider _rsa;
private string _privatekey;
private string _publickey;
private int _keyid;
public override void GenerateKey()
_rsa = new RSACryptoServiceProvider();
this._privatekey = _rsa.ToXmlString(true);
this._publickey = _rsa.ToXmlString(false);
this._keyid = -1;
catch (Exception e)
StringBuilder sb = new StringBuilder();
sb.AppendLine("Error in GenerateKey() method.");
throw new ApplicationException(sb.ToString(), e);