get_Range function throws an exception

  • Thread starter Thread starter Mikil
  • Start date Start date
M

Mikil

I am communicating with Excel Interop dll using c#. The get_Range
function throws an exception if the parameters are invalid. For e.g.
get_Range("Mikil", Type.Missing); will crash if the "Mikil" named range
is not present.
Why the does the function crash instead of returning "null"?
 
Mikil,

What is the exception that is being thrown?

Are you sure that is the line of code that is throwing the exception,
and that you aren't trying to access an object reference set to null?
 
it throws a System.Runtime.InteropServices.COMException (0x800A03EC).

The exception is thrown on the following line :
ExcelApplication.get_Range("Mikil", Type.Missing); /// the
ExcelApplication object is not null
 
Mikil,

What are the details of the exception? Any message or anything like
that?
 
Following the Exception :

"System.Runtime.InteropServices.COMException (0x800A03EC): Exception
from HRESULT: 0x800A03EC.\r\n at
Bently.System1.ExcelInterop._Application.get_Range(Object Cell1, Object
Cell2)\r\n at PPExcelAddin.CExcelUIHandler_MenuClick(CommandBarButton
Ctrl, Boolean& CancelDefault) in o:\\ppexceladdin\\ppexceladdin.cs:line
1033"
 
The arguments passed to the COM method are invalid, this results in an error
HRESULT (0x800A03EC) returned from the COM server. COM interop has to
translate all error HRESULTS in a COMException, this is part of the interop
protocol and is consistent with the native client COM protocol. You should
never assume there is something returned if HRESULT is not S_OK, there
isn't.

Willy.


| Following the Exception :
|
| "System.Runtime.InteropServices.COMException (0x800A03EC): Exception
| from HRESULT: 0x800A03EC.\r\n at
| Bently.System1.ExcelInterop._Application.get_Range(Object Cell1, Object
| Cell2)\r\n at PPExcelAddin.CExcelUIHandler_MenuClick(CommandBarButton
| Ctrl, Boolean& CancelDefault) in o:\\ppexceladdin\\ppexceladdin.cs:line
| 1033"
|
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top