我对某事感到困惑。
我有一个使用后台代理计划任务的 Windows Phone 8 应用程序。
除其他外,后台代理使用此处找到的解压缩器下载并提取 .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 中的流(称为“this.stream”)是一个 MS.Internal.InternalMemoryStream。但是,当后台代理到达后台 Unzipper.cs 中的同一行时,“this.stream”是一个 MS.Internal.ReadOnlyBufferedStream。
这是我发现的唯一区别。但是,我什至不确定这是否是问题所在。它正在抛出 System.NotImplementedException
reader.BaseStream.Seek(-4, SeekOrigin.End);
但实际上,MS.Internal.ReadOnlyBufferedStream 确实具有“true”的“CanSeek”属性(我注意到 Unzipper 会检查它,如果它是 false,则抛出 NotSupportedException。)
我被难住了。事实上,谷歌搜索“MS.Internal.ReadOnlyBufferedStream”不会产生单一结果(尽管我猜现在会......)