什么是MS.Internal.ReadOnlyBufferedStream(在Windows Phone后台代理中)? [英] What is MS.Internal.ReadOnlyBufferedStream (in Windows Phone background agents)?

查看:114
本文介绍了什么是MS.Internal.ReadOnlyBufferedStream(在Windows Phone后台代理中)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的应用程序中,我有一个后台代理,试图将文件解压缩到后台代理中.

In my application, I have a background agent that attempts to unzip a file in a background agent.

我注意到它失败了,问题似乎出在常规(前景)代码中来自WebClient下载的流(其类型为MS.Internal.InternalMemoryStream类型)无法解释地变成了MS.Internal.ReadOnlyBufferedStream.相同的代码 在后台代理中执行.

I noticed it is failing, and the issue seems to be that the stream from a WebClient download, which is of type MS.Internal.InternalMemoryStream in the regular (foreground) code, inexplicably becomes an MS.Internal.ReadOnlyBufferedStream when the same code executes in the background agent.

我似乎找不到有关此MS.Internal.ReadOnlyBufferedStream的任何信息,但是当从此流的BinaryReader上调用Seek方法时,它将失败:

I can't seem to find any information about this MS.Internal.ReadOnlyBufferedStream, but it fails when the Seek method is called on a BinaryReader from this stream:

BinaryReader reader = new BinaryReader (this.stream);

reader.BaseStream.Seek(-4, SeekOrigin.End);

这将引发System.NotImplementedException:

this throws a System.NotImplementedException:

System.NotImplementedException: The method or operation is not implemented.
    at MS.Internal.XcpImports.CheckHResult(UInt32 hr)
    at MS.Internal.XcpImports.SeekInternalStream(IntPtr element, Int64 offset, SeekOrigin origin, Int64& newPosition)
    at MS.Internal.ReadOnlyBufferedStream.Seek(Int64 offset, SeekOrigin origin)

就像我说的那样,我似乎无法在网络上的任何地方找到任何有关此类流的信息,甚至无法提及.  

Like I said, I can't seem to find ANY information, or even mention, of this kind of stream, anywhere on the web.  

有人遇到过这样的视频流吗?  

Has anyone encountered a stream of this sort?  

我还要指出,该流具有一个属性"CanSeek",没错.

I'd also like to note that the stream has a property "CanSeek" which is true.


推荐答案

来自WebClient下载的流

the stream from a WebClient download

我不知道Microsoft如何在内部实现该流,但是我不会依赖始终可搜索的网络流.根据我的经验,流往往在下载所有数据之前返回.   这可能意味着它是可搜索的, 但是流的长度未知,因此无法在特定时间进行搜索.

I don't know how Microsoft implemented the stream internally, but I wouldn't rely on a network stream always being seekable.  In my experience streams tend to be returned before all the data is downloaded.   That may mean that it is seekable, but the Length of the stream isn't known, so it can't seek at that particular time. 

一种解决方案是将数据作为各种临时文件写入隔离存储中,然后从那里解压缩.这样,您可以保证流处于所需状态.

A solution would be to write the data to isolated storage as a temp file of sorts, and then unzip from there.  That way you can guarantee that the stream is in the state you need it.


这篇关于什么是MS.Internal.ReadOnlyBufferedStream(在Windows Phone后台代理中)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆