Stream does not support writing exception

Dec 29, 2009 at 11:43 AM

Hi.

I just downloaded and tried to run the sample application. However, I get a NotSupportedException, "Stream does not support writing exception" in SeekableStream.cs , line 127:  base.Write(_asyncStreamBuffer, 0, contentReadTotal);

Any ideas?

Coordinator
Dec 29, 2009 at 5:56 PM

Hi,

I wrote the SeekableStream to be read-only for the purposes of downloading Media content only.

And as well, the method in which I implemented it does not work for Writeable streams. It uses a MemoryStream internally which is asynchronously filled.

If you wanted to write to SeekableStream then, it will be writing to the internal MemoryStream and this would break the abstraction since all derived Stream classes are readable but not all are writeable, such as Microsoft's Internal NetworkStream which is what HttpWebRequest uses internally.

There are a few restrictions with Microsoft's internal network stream, the major one being that it is not seekable.

Thinking about it, I should actually make it Writeable because if the underlying stream (the one passed into the SeekableStream constructor) does not support Write, then the same Exception will be thrown. I will look into this but it also means that I have to test it with a few other Stream types to make sure it is robust.

I'll update any developments here specific to this issue.

 

Jan 5, 2010 at 3:02 PM

Hi.

Thanks for your reply.

But I don't understand. I downloaded the solution and just ran it by pressing F5. I didn't change anything, and it crashes right away without my doing anything.

Oh well... I will have to look somewhere else for a Silverlight streaming solution.

/M

 

Coordinator
Jan 5, 2010 at 6:48 PM

After some prelimanary testing, I've decided not to make the SeekableStream writeable.

It incurs a sizeable overhead for what it was intended to be, that is, a readable seekable stream.

Instead of giving up on the project, you should have posted the errors you are encountering so that I could have tried to fix it and make the fix available to others.

Oh well, good luck with your search.

Jan 6, 2010 at 7:21 AM

Hi.

Thanks for your reply.

I did post the error in my first message.

However, for full details, here is the complete error message:

System.NotSupportedException was unhandled by user code
  Message="Stream does not support writing."
  StackTrace:
       at System.IO.MemoryStream.Write(Byte[] buffer, Int32 offset, Int32 count)
       at Saluse.MediaKit.IO.SeekableStream.FillMemoryStreamFromSourceStream(Object state)
       at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Threading.ThreadHelper.ThreadStart(Object obj)
  InnerException: 

It occurs at method base.Write(_asyncStreamBuffer, 0, contentReadTotal); , line 127 in SeekableStream.cs

 

Coordinator
Jan 6, 2010 at 6:36 PM

When you load the solution (VS2008 or VS2010?), is "Saluse.MediaKit.Sample.Web" the startup project and "Saluse.MediaKit.SampleTestPage" the startup page?

 

Jan 7, 2010 at 7:03 AM

Hi.

VS2008

"Saluse.MediaKit.Sample.Web 2008" is the startup project and "Saluse.MediaKit.SampleTestPage.aspx" is the startup page.

However, I just found out that this error is only thrown on a Windows XP box. On a Windows 7 box, it seems to be working fine.

 

 

Feb 13, 2010 at 2:18 PM

@MagnusJ - I only get this error when I run it on a computer that has the SL4 beta run-time installed. Do you think that is also the reason you got the error?

 

Feb 20, 2010 at 5:28 PM

See:

http://salusemediakit.codeplex.com/WorkItem/View.aspx?WorkItemId=11785

For the two methods to replace in SeekableStream.cs to resolve this issue in Silverlight 4.