我被一些事情搞糊涂了。
我有一个使用后台代理计划任务的Windows Phone 8应用程序。
除其他功能外,后台代理还使用unzipper found here下载并提取.zip文件。(解压缩功能在应用程序的常规非后台部分运行良好。)
我注意到后台代理抛出了一个System.NotImplementedException,我跟踪到了Unzipper.ParseCentralDirectory()中的一行代码。
private List<FileEntry> ParseCentralDirectory()
{
BinaryReader reader = new BinaryReader(this.stream);
//this next line is the one that's throwing the System.NotImplementedException
reader.BaseStream.Seek(-4, SeekOrigin.End);在本例中,BinaryReader参数中的"this.stream“定义在类的顶部:
public sealed class Unzipper : IDisposable
{
private Stream stream;
...正如我所提到的,unzipper功能在常规的主应用程序中运行良好。因此,我在主应用程序和后台应用程序之间寻找相关代码部分的差异( unzipper类分别出现在主项目和后台代理项目中)。
我注意到Unzipper中的流(引用为"this.stream")是一个MS.Internal.InternalMemoryStream。但是,当后台代理到达后台Unzipper.cs中的同一行时,"this.stream“是MS.Internal.ReadOnlyBufferedStream。
这是我发现的唯一区别。然而,我甚至不确定这是否是问题所在。它正在使用System.NotImplementedException
reader.BaseStream.Seek(-4, SeekOrigin.End);但事实上,MS.Internal.ReadOnlyBufferedStream确实有一个"CanSeek“属性"true”(我注意到Unzipper会检查它,如果为false就抛出一个NotSupportedException )。
我被难住了。实际上,在谷歌上搜索"MS.Internal.ReadOnlyBufferedStream“不会得到任何结果(尽管我猜现在会...)
发布于 2013-04-11 11:30:56
对于大多数基于网络的API,后台代理与其前台对应物相比具有显著不同的实现。
我所能推荐的就是将数据流式传输到隔离存储中的临时文件,然后打开该文件的数据流进行解压缩。
请记住,您只有6mb的内存(RAM)可供使用,包括您的应用程序程序集,在此之后,您的任务将被终止(如果它发生3次,则不会被调度)。这可能会导致解压缩时出现内存问题。
https://stackoverflow.com/questions/15938358
复制相似问题