【发布时间】:2014-05-15 03:40:24
【问题描述】:
我正在尝试使用 C#.NET 阅读 epub 书,但出现以下异常: 对象引用未设置为对象的实例。
我是第一次尝试 epub,this 是我推荐的地方。
代码:
static void Main(string[] args)
{
try
{
Epub book = new Epub(@"d:\test.epub"); //this is the line where i am getting error
String Title = book.Title[0];
String Author = book.Creator[0];
Console.WriteLine("Name:" + Title);
Console.WriteLine("Author:" + Author);
}
catch (Exception e)
{
Console.WriteLine("Exception: " + e.Message);
}
Console.ReadKey();
}
有什么想法吗??谢谢!!
【问题讨论】:
-
test.epub文件可能已损坏或具有意外的(从 lib 的角度来看)格式。您拥有的所有epub文件都会发生这种情况吗? -
@GrantWinney 我尝试了单步调试,异常在同一行。尝试将文件移动到桌面,我的文档但没有任何变化。
-
@Downvoter:我在这里发布之前已经完成了那个答案,但它谈到了对象如何为空以及如何在访问它之前检查它是否不为空。
-
@aleksey.berezan 谢谢,这有帮助。尝试了很多方法,但不是您建议的方法。它现在工作正常。:-)
-
@lambda,很高兴它有帮助:)