From: Family Tree Mike on
On 5/20/2010 1:20 PM, shapper wrote:
> On May 20, 5:26 pm, Family Tree Mike<FamilyTreeM...(a)ThisOldHouse.com>
> wrote:
>> On 5/20/2010 11:57 AM, shapper wrote:
>>
>>
>>
>>> Hello,
>>
>>> I have a class that writes to a MemoryStream but I am getting a
>>> strange error:
>>
>>> ReadTimeout = '((System.IO.Stream)(s)).ReadTimeout' threw an exception
>>> of type 'System.InvalidOperationException'
>>
>>> base {System.SystemException} = {"Timeouts are not supported on this
>>> stream."}
>>
>>> Source = "mscorlib"
>>
>>> WriteTimeout = '((System.IO.Stream)(s)).WriteTimeout' threw an
>>> exception of type 'System.InvalidOperationException'
>>
>>> base {System.SystemException} = {"Timeouts are not supported on this
>>> stream."}
>>
>>> Source = "mscorlib"
>>
>>> Any idea why might be wrong?
>>
>>> I really have no idea.
>>
>>> Thank You,
>>
>>> Miguel
>>
>> I see you are posting this and at least one other question here and to
>> the forums as well.
>>
>> MemoryStreams don't support timeouts and it is documented that some
>> streams throw an exception. If you have a timeout on a memory stream,
>> you have bigger concerns to worry about, like needing a new computer...
>>
>> --
>> Mike
>
> Sorry, both questions are related to the same problem.
> The first is to solve it and the second is an alternative I am trying
> to use to check if it solves it.
>
> This is driving me crazy for hours and I decided to post in the two
> different forums to try to get some help.
> Didn't know the forums are related ....
>
> Should I post only in one? Which one? I just though the communities
> were different ...
>
> Sorry but it sounds strange this is a problem with my computer ...
>
> Maybe the fact that I am using NET 4.0?
>
> The CSVWriter class is:
> http://kbcsv.codeplex.com/SourceControl/changeset/view/42031#530488
>
> I can't find what might be the problem ...

Find the line that the exception occurs. This line is presumably a
WriteTimeout or ReadTimout property on a stream being set. If this is
in the CSVWriter class, then the class has a bug, because it cannot work
with MemoryStreams. If it is your code, it is because you cannot set
the properties. Setting the properties throws this exception, not a
timeout during your read/write with the memory stream. This is because
memory streams do not timeout. They cannot time out.

--
Mike