2013-11-21 94 views
1

一個定義,因爲從VS2010升級項目,VS2012我得到的錯誤:「系統.__ ComObject」不包含.WithComCleanup()

'System.__ComObject' does not contain a definition for .WithComCleanup())

運行這段代碼的命令行時間:

using (var cell = usedRange.Resource.Find(reservedWord, LookIn: XlFindLookIn.xlFormulas, After: usedRange.Resource.Cells[usedRange.Resource.Rows.Count, usedRange.Resource.Columns.Count]).WithComCleanup()) 

回答

2

想我會分享解決這個惱人的問題,在中間窗口中執行線時,你得到的提示:

Embedded interop type 'Microsoft.Office.Interop.Excel.XlFindLookIn' is defined in both 'Excel.dll' and 'XYZ.ExcelAddin.ABC.dll'. Some operations on objects of this type are not supported while debugging. Consider casting this object to type 'dynamic' when debugging or building with the 'Embed Interop Types' property set to false.

我通過將嵌入Interop類型爲False來解決問題,以供參考DLL Microsoft.Office.Interop.Excel