简体   繁体   中英

Excel Interop Error On Workbook Open

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!

I fixed that issue.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM