I'd like to use a constructor to establish objects for my class. The problem is that the constructor executes properly (stepped over each assignment within the constructor in the Visual Studio debugger), however after the constructor finishes and the object is established, I can't use any of my class's methods to access the data members.
There seems to be a disconnect between the data members listed above the constructor and the data members assigned inside the constructor.
The error that posts is: "NullReferenceException Unhandled - Object reference not set to an instance of an object."
...
using Microsoft.Office.Interop.Excel;
using System.Runtime.InteropServices;
using System.IO;
namespace ExcelManip
{
class ExcelInterop
{
//MEMBERS
private Application _excelApp;// = new Application();
private Workbooks books;
private Workbook workBook;
//CONSTRUCTOR
public ExcelInterop(string thisFileName)
{
Application _excelApp = new Application();
Workbooks books = _excelApp.Workbooks;
Workbook workBook = books.Open(thisFileName,
Type.Missing, Type.Missing, Type.Missing, Type.Missing,
Type.Missing, Type.Missing, Type.Missing, Type.Missing,
Type.Missing, Type.Missing, Type.Missing, Type.Missing,
Type.Missing, Type.Missing);
}