I am trying to read epub book using C#.NET but I am getting the following excetion: Object reference not set to instance of an object.
I am trying epub for the first time and this is where I have referred.
Code:
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();
}
Any ideas?? Thanks!!
I've tried to run your code locally and it worked on my machine. And it works for other epub
files, as you've said in comment.
Also I've taken a brief look into Epub's code-base and didn't find anything that could obviously cause the error, plus NullReferenceException
means that:
epub
file is broken or corrupted epub
file does not have some specific piece of (meta)data that Epub
lib expects. In both cases I'd recommend you to try to re-create/re-convert that not working d:\test.epub
file or abandon it :)