Having trouble debugging a System.Runtime.InteropServices.COMException on Application.Run

684 Views Asked by At

I have an Excel function that I'm calling from C# as follows:

string result = xlApp.Run("'ExcelBook.xlsm'!mainFromBatch", 
                          "http://someSite/TestFile.xlsm",
                          false, 
                          "T:\\somePath");

When run, this raises an error:

An exception of type 'System.Runtime.InteropServices.COMException' occurred
in BatchConverter.exe but was not handled in user code

Additional information: Exception from HRESULT: 0x800ADF09

If there is a handler for this exception, the program may be safely continued.

The function header for mainFromBatch is:

Function mainFromBatch(sourceBkPath As String, Flag As Boolean, _
                       Optional outputPathFromConfig As String) As String

When I put a breakpoint at this function header in the VBA code of ExcelBook.xlsm, the C# code raises the error, but the Excel breakpoint is reached and Excel pauses there, as though no error had occurred and it's ready to execute the rest of the code.

I'm able to use C# to call other functions from this workbook without a problem.

I tried Googling the HRESULT code but didn't find anything.

Any idea what's going on here?

0

There are 0 best solutions below