如何解决Xamarin表单-Epub:System.AggregateException:发生一个或多个错误
我正在将我的epub文件URL转换为流并将其存储为本地字节,如下所示:
Stream stream;
HttpClient client = new HttpClient();
var response = await client.GetAsync(fileUrl);
stream = await response.Content.ReadAsStreamAsync();
epubBook = EpubReader.ReadBook(stream);
//saving to folder
byte[] bytes = await response.Content.ReadAsByteArrayAsync();
string filename = Path.GetFileName(fileUrl);
var folderPath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
var filePath = Path.Combine(folderPath,filename);
File.WriteAllBytes(filePath,bytes);
这对于大多数文件都可以正常工作。但是有些文件网址显示System.AggregateException
。
异常详细信息
System.AggregateException:发生一个或多个错误。 (版本号“ 1.1”无效。第1行,位置16。)---> System.Xml.XmlException:版本号“ 1.1”无效。第1行,位置16。 在:0中的System.Xml.XmlTextReaderImpl.Throw(System.Exception e)[0x00027]处 在:0中的System.Xml.XmlTextReaderImpl.Throw(System.String res,System.String arg)[0x00029]处 在:0中的System.Xml.XmlTextReaderImpl.ParseXmlDeclaration(System.Boolean isTextDecl)[0x0061f]处 在:0中的System.Xml.XmlTextReaderImpl.Read()[0x000c6]处 在:0中的System.Xml.Linq.XDocument.Load(System.Xml.XmlReader阅读器,System.Xml.Linq.LoadOptions选项)[0x00016]中 在:0中的System.Xml.Linq.XDocument.Load(System.IO.Stream流,System.Xml.Linq.LoadOptions选项)[0x0000f]处 在:0中的System.Xml.Linq.XDocument.Load(System.IO.Stream流)[0x00000]处 在:0中的VersOne.Epub.Internal.XmlUtils + c__DisplayClass0_0.b__0()[0x00000]中 在System.Threading.Tasks.Task`1 [TResult] .InnerInvoke()[0x0000f]在:0中 在:0中的System.Threading.Tasks.Task.Execute()[0x00000]处 ---从之前引发异常的位置开始的堆栈跟踪---
有此问题的示例文件URL:
我正在使用EpubReader.Cross Nuget来解析epub文件。
为了方便参考,我上传了一个示例project。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。