문제

Since upgrading a project from VS2010 to VS2012 I'm getting the error:

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

When running this command line of code:

using (var cell = usedRange.Resource.Find(reservedWord, LookIn: XlFindLookIn.xlFormulas, After: usedRange.Resource.Cells[usedRange.Resource.Rows.Count, usedRange.Resource.Columns.Count]).WithComCleanup())
도움이 되었습니까?

해결책

Thought I'd share the solution to this annoying problem, when executing the line in the intermediate window you get the tip:

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.

I solved the problem by turning Embed Interop Types to False for the reference DLL Microsoft.Office.Interop.Excel

다른 팁

I solved the problem by turning Embed Interop Types to False for the reference DLL Microsoft.Office.Interop.Excel, but I get message:

System.IO.FileNotFoundException: "Could not load file or assembly 'office, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c'. Не удается найти указанный файл."
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top