I got this error
ReadTimeout = \'((System.IO.Stream)(ms)).ReadTimeout\' threw an exception of type \'System.InvalidOperationException\'.
M
The ReadTimeout property must be overridden, in the base System.IO.Stream class it always throw System.InvalidOperationException error by design.
The solution is not to cast ms to the base type when reading the timeout:
int readTimeout = ms.ReadTimeout;
Edit: didn't check before posting.. MemoryStream also does not override that property - meaning timeout for such stream is not implemented.
You have to either use other implementation of Stream class that does override the ReadTimeout property, or write your own implementation.