COMException (0x80010108 - RPC_E_DISCONNECTED) When exiting Excel.Workbook

When I run the following code, I get an exception below:

''# NOTE: ExcelApp is a Private main form variable
Dim ReportBooks As Excel.Workbooks = ExcelApp.Workbooks
Dim ReportBook As Excel.Workbook = ReportBooks.Open(localFilename)
Dim ReportSheet As Excel.Worksheet = ReportBook.Sheets("Report")

''# Retreive data from sheet

ReleaseCOM(ReportSheet)
ReportBook.Close(True) ''# Error raised here
ReleaseCOM(ReportBook)
ReleaseCOM(ReportBooks)
ERROR:
COMException was unhandled
The object invoked has disconnected from its clients.
(Exception from HRESULT: 0x80010108 (RPC_E_DISCONNECTED))

Note. All data appears to have been returned correctly.

Please help me diagnose and overcome this error.

+3
source share
2 answers

RPC_DISCONNECTED ... scary "The called object has disconnected from its clients." question. There are many reasons for this, it looks like you looked at the problem of global variables with Excel.. Can you put the first one ReleaseCOM(ReportSheet)below ReportBook(Close)and run it? Also check out this one .

+6

, , .

Excel Automation COM Interop ?

SpreadsheetGear .NET Excel / / /etc... , COM Interop.

ASP.NET- , .

: SpreadsheetGear LLC

-2

Source: https://habr.com/ru/post/1736401/


All Articles