2013年8月13日 星期二

C# 輸出 Excel 出現找不到 Marshal.GetTypeFromCLSID 方法


用 C# 輸出 Excel,在自己的電腦可以正常執行,
但到其他電腦卻不行,出現以下錯誤訊息:

System.MissingMethodException: 找不到方法: 'System.Type System.Runtime.InteropServices.Marshal.GetTypeFromCLSID(System.Guid)'

(System.MissingMethodException: Method not found: 'System.Type System.Runtime.InteropServices.Marshal.GetTypeFromCLSID(System.Guid)')

後來發現是 .NET Framework 版本的問題,要 4.5 才有支援 Marshal.GetTypeFromCLSID 方法
將其他電腦安裝 .NET Framework 4.5 後就解決了。

官網說明
http://msdn.microsoft.com/zh-tw/library/system.runtime.interopservices.marshal.gettypefromclsid.aspx
Marshal.GetTypeFromCLSID 方法,支援版本:4.5

安裝 Microsoft .NET Framework 4.5
網址:http://www.microsoft.com/zh-tw/download/details.aspx?id=30653


參考
http://stackoverflow.com/questions/12655236/excel-interop-missingmethodexception
https://github.com/bcleary/outlook-gmail-rules-export/issues/3

沒有留言:

張貼留言