Error creating .exe
-
Hello, I am trying to write a simple console app that reads the data contained in specific Excel spreadsheet cells, and use that data to write an .xml file with the XmlTextWriter class. when I go to compile the code, I get an error that says it does not recognise 'using Excel;' and that I may be missing a reference. The thing is I had already added the Excel reference from the Project > Add Reference.. dialog. I run into this error before when writing to an Excel worksheet and after I clicked 'Yes' to continue in the 'Build Errors' dialog, the app ran perfectly, but not this time. I now get an error that says VS cannot start debugging beacuse the debug target \Program.exe is missing. I have never seen this before, can anyone help me? The code below is an extract on my class: class Program { static void Main(string[] args) { //directory of XLS file to be read from string xlsDir = ""; bool xlsError = false; XmlTextWriter writer = new XmlTextWriter("C:\\My Documents\\test1.xml", _UnicodeEncoding); writer.Formatting = Formatting.Indented; int countVPS = 0; //to increment the VPSnodes array string[] VPSnodes = new string[5] { vendorID, vendor, copyright, version, _schemaVersion }; //opens dialog to browse directories and open a file OpenFileDialog openFile = new OpenFileDialog(); openFile.InitialDirectory = "c:\\My Documents"; openFile.Filter = "xls files (*.xls)|*.xls*|xml files (*.xml)*.xml*| _All files (*.*)|*.*"; if (openFile.ShowDialog() == DialogResult.OK) { xlsDir = openFile.FileName; Excel.Workbook wb = this.Application.Workbooks.Open(xlsDir); // activate the active worksheet in the workbook (Microsoft.Office.Interop.Excel._Workbook) _this.Application.Workbooks[1]).Activate(); ((Excel.Worksheet)this.Application.ActiveWorkbook.ActiveSheet); try { if (ExcelObj == null) { Console.WriteLine("\nERROR: EXCEL couldn't be started!"); xlsError = true; } if (xlsError == false) { writer.WriteRaw(""); writer.WriteStartElement("vendorProductSet"); for (int colV = 1; colV <= 5; colV++) { writer.WriteAttributeString(nodes[countVPS], _((Range)ws.Cells[2, col]).Value2); countVPS++;