471,071 Members | 8,630 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,071 software developers and data experts.

CryptoStream calls Write when it shouldn't

Hi!

In my code I create a CryptoStream around another stream of my own, with
CryptoStreamMode.Read. So I just can read from the CryptoStream. When I
close that CryptoStream, however, the underlying stream's Write() method is
called, with an empty buffer (offset and count-parameters are also 0). My
streams' CanWrite property returns false, so the CryptoStream should not
call Write(). It shouldn't call Write() at all, because I created it with
CryptoStreamMode.Read.
The problem with it is, the Write() method of my stream throws a
NotSupportedException, and that's ok because it doesn't support writing. But
the CryptoStream doesn't seem to catch the exception, so it is directly
raised and executions stops. I cannot work with that but I still have to
throw the exception. It makes no sense not having my Write() method throw
that Exception.
What's going wrong ?

Thanks
Daniel
Nov 15 '05 #1
0 1137

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

7 posts views Thread by Stingray | last post: by
5 posts views Thread by weixiang | last post: by
7 posts views Thread by pseudonym | last post: by
2 posts views Thread by pesso | last post: by
1 post views Thread by Nicholas Holder | last post: by
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.