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:

https://s3.us-east-1.amazonaws.com/catholic-brain/prod/dc/cbrain-app/files/doc-lib/2020/08/10/12/56/42/068/head/9781612781495_EPUB.epub

https://s3.us-east-1.amazonaws.com/catholic-brain/prod/dc/cbrain-app/files/doc-lib/2020/08/10/07/36/06/376/head/9781612781358_EPUB.epub

我正在使用EpubReader.Cross Nuget来解析epub文件。

为了方便参考,我上传了一个示例project

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

依赖报错 idea导入项目后依赖报错,解决方案:https://blog....
错误1:代码生成器依赖和mybatis依赖冲突 启动项目时报错如下...
错误1:gradle项目控制台输出为乱码 # 解决方案:https://bl...
错误还原:在查询的过程中,传入的workType为0时,该条件不起...
报错如下,gcc版本太低 ^ server.c:5346:31: 错误:‘struct...