Excel interop MissingMethodException

Mah*_*der 6 c# excel interop exception

在我的C#程序中,我正在使用Excel 2010互操作程序集.有了这个,我正在读取和写入excel文件的数据.并在开发框上执行正常(包含Office 2010).在客户端计算机上,即使它们具有Office 2010和Office PIA,也会看到下面的异常,在WriteToExcel()方法调用时引发.

Unhandled Exception: System.MissingMethodException: Method not found: 'System.Type System.Runtime.InteropServices.Marshal.GetTypeFromCLSID(System.GUID)'.
Run Code Online (Sandbox Code Playgroud)

以下是我的代码段.

[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            
 }
Run Code Online (Sandbox Code Playgroud)

Mah*_*der 5

将.net版本降低到4.0后问题解决了.早些时候我的devbox有4.5,应用程序是用这个版本编译的.我的客户端机器有4.0版本,降低.net版本解决了这个问题.