Hi all,

Here is the scenario. I have an asp.net page, that uses remoting to invoke a COM+ 
object elsewhere. The remote object it invokes, is actually a wrapper for the COM+ 
object, and is hosted in IIS. Here is some code that it executes:

Dim reader As System.IO.FileStream
Dim decryptorStream As CryptoStream
reader = New System.IO.FileStream("c:\myfile.enc", System.IO.FileMode.Open)
Dim cryptoProvider As DESCryptoServiceProvider = New DESCryptoServiceProvider()
decryptorStream = New CryptoStream(reader, _
cryptoProvider.CreateDecryptor(cCryptokey, cCryptokey), _
CryptoStreamMode.Read)
Dim decryptedBytes(Convert.ToInt32(reader.Length)) As Byte
decryptorStream.Read(decryptedBytes, 0, Convert.ToInt32(reader.Length))
decryptorStream.Close()
reader.Close()

The first time I load the asp.net page, this works fine, I step through it, everything 
is great.  If I then reload the page, which calls the method that contains this code, 
I get a CryptographicException with the message "Bad Data" on the 
"decryptorStream.Read" line, which tells me nothing. The first time this code 
executes, the contents of the file seem to be acceptable, but not any other times. If 
I shut down the asp.net process, the first time page loads fine, if I reload, this 
happens.
Any ideas as to why this is happening?

Thanks,
Marina

You can read messages from the DOTNET archive, unsubscribe from DOTNET, or
subscribe to other DevelopMentor lists at http://discuss.develop.com.

Reply via email to