Excel Interop Error On Workbook Open

0

I got an error when trying to open excel workbook:

var workbook = Workbooks.Open(filePath)

After that every time I've got:

Exception from HRESULT: 0x80020005 (DISP_E_TYPEMISMATCH)

What is interesting, when im using Thread.Sleep(2000) before "Open" function everything is working correctly:

Thread.Sleep(2000);

var workbook = Workbooks.Open(filePath)

Code is running on main thread.

Any ideas what should cause that behavior?

Thanks!

c#
excel
office-interop
asked on Stack Overflow Nov 3, 2016 by Greg

1 Answer

0

I fixed that issue.

Excel workbook was opening two times and each time I was calling releaseCom method.

answered on Stack Overflow Nov 4, 2016 by Greg

User contributions licensed under CC BY-SA 3.0