在我的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)'.
以下是我的代码片段。
[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
}