Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Excel interop MissingMethodException

In my C# program, I am using Excel 2010 interop assembly. With this i am reading & writing data to excel file. And executing fine on dev box (contains Office 2010). On client machine, even though they have Office 2010 and Office PIA, there are seeing below exception, raises at WriteToExcel() method call.

Unhandled Exception: System.MissingMethodException: Method not found: 'System.Type System.Runtime.InteropServices.Marshal.GetTypeFromCLSID(System.GUID)'.

Below is my code snippet.

[STAThread]
static void Main(string[] args){

       // read user input, process and write data to Excel
       WriteToExcel();
 }

[STAThread]
static void WriteToExcel(){
     Application xlsApplication = new Application();
     Workbook xlsWorkbook = xlsApplication.Workbooks.Open(excelFilePath);
     // write data to excel
     // close up            
 }
like image 964
Mahender Avatar asked Sep 29 '12 18:09

Mahender


1 Answers

Issue solved after lowering .net version to 4.0. Earlier My devbox has 4.5 and application is compiled with this version. My client machine has 4.0 version, lowering .net version solved the issue.

like image 62
Mahender Avatar answered Oct 10 '22 03:10

Mahender