I am getting this error on RetrieveBookList, RetrieveBook and StoreBookList, although it works on StoreBook. I think there is an issue with my generic list because when i just called one book, I didn't recieve this error. Cannot figure out where I went wrong though. Any help would be appreciated.....
public class BookSvcBinImpl : IBookService
{
public void StoreBook(Book bookx)
{
IList<Book> listBooks = new IList<Book>();
FileStream saveStream = new FileStream("Book.bin", FileMode.Create, FileAccess.Write);
IFormatter formatter = new BinaryFormatter();
formatter.Serialize(saveStream, bookx);
saveStream.Close();
}
public Book RetrieveBook()
{
FileStream loadStream = new FileStream("Book.bin", FileMode.Open, FileAccess.Read);
//IFormatter formatter = new BinaryFormatter();
IList<Book> listBooks = formatter.Deserialize(loadStream) as IList<Book>;
//Book bookX = formatter.Deserialize(loadStream) as Book;
loadStream.Close();
//return bookX;
}
}
public interface IBookService : IService
{
void StoreBook(Book bookx);
void StoreBookList(Book[] bookx);
void RetrieveBook(Book bookx);
Book[] RetrieveBookList(int maxcount);
//Book RetrieveBook();
}
private void SubmitBtn_Click(object sender, EventArgs e)
{
this.AcceptButton = AddSubmitBtn; // Enables button when enter is pushed
IList<Book> listBooks = new IList<Book>();
Book book = new Book();
book.isbn = AddISBNTxt.Text;
book.status = AddStatusTxt.Text;
book.title = AddTitleTxt.Text;
book.series = AddSeriesTxt.Text;
book.author = AddAuthorTxt.Text;
book.description = AddDescTxt.Text;
//book.addition = ConfirmBox.
BookMgr bookMgr = new BookMgr();
bookMgr.CreateBook(book);
MessageBox.Show("Book has been added!");
}