Question

I have a function thus:

   public static void ProcessWorkSheet(string fileName, string month, string year,
     string thread)
    {
        //version number location
        int version_row = 10;
        int version_column = 2;

        SeedsDBEntities db = new SeedsDBEntities();

        try
        {
            //Instance of Excel
            ExcelApp = new Microsoft.Office.Interop.Excel.Application();

            ExcelApp.Visible = true;

            ExcelApp.DisplayAlerts = false;

            WorkBook = ExcelApp.Workbooks.Open(@fileName, 0, false, 5, "", "", false, Microsoft.Office.Interop.Excel.XlPlatform.xlWindows, "", true, false, 0, true, false, false);
            (Microsoft.Office.Interop.Excel.Worksheet)WorkBook.Worksheets.get_Item(month);
                    .
                    .

            //the rest of the code
     }

I am using Microsoft.Interop library to read from an excel sheet and save it to a database. the issue here is that i get an "Object reference not set to an instance of an object" exception when the code tries opening the workbook on IIS 8. It works well on visual studio 2010. What could be the problem.

Was it helpful?

Solution

I had to give IIS User permission to use the Application. Create a folder C:\Windows\SysWOW64\config\systemprofile\Desktop for 64-bits Systems and set the permission settings to allow for IIS user.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top