473,385 Members | 1,958 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

get_Range function throws an exception

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"?

May 25 '06 #1
5 9221
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?
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Mikil" <mi**********@gmail.com> wrote in message
news:11*********************@i39g2000cwa.googlegro ups.com...
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"?

May 25 '06 #2
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

May 25 '06 #3
Mikil,

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

--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Mikil" <mi**********@gmail.com> wrote in message
news:11**********************@j33g2000cwa.googlegr oups.com...
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

May 25 '06 #4
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(CommandBarB utton
Ctrl, Boolean& CancelDefault) in o:\\ppexceladdin\\ppexceladdin.cs:line
1033"

May 25 '06 #5
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.
"Mikil" <mi**********@gmail.com> wrote in message
news:11*********************@u72g2000cwu.googlegro ups.com...
| 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(CommandBarB utton
| Ctrl, Boolean& CancelDefault) in o:\\ppexceladdin\\ppexceladdin.cs:line
| 1033"
|
May 25 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
by: Eric Lilja | last post by:
Hello, I'm working with a hash table that is encapsulated in a class. One of its member functions insert() throws an exception if the insertion fails (for example, if the value was already present...
2
by: Daniel | last post by:
if System.IO.StreamWriter write throws an exception, is there anyway to close the System.IO.StreamWriter object? it seems to stay open when this happens then future attempts to write to that same...
27
by: sklett | last post by:
I just found myself doing something I haven't before: <code> public uint Duration { get { uint duration = 0; foreach(Thing t in m_things) { duration += t.Duration;
3
by: benben | last post by:
I have always found Stroustrup's paper on generalized member function wrapper (http://www.research.att.com/~bs/wrapper.pdf) an interesting one. Recently I started to play with it. As I tried to put...
6
by: Jack White | last post by:
Does anyone know if an analogue to the "swap()" function found in C++ exists in C#. For those not familiar, let's say you have a function that loads some collection passed in by reference. If an...
3
by: Sugandh Jain | last post by:
Hi. How to write a function that will return me the factorial (say in a string) for the any positive integer it takes? When we find a factorial of even say 2000 or a higher number, it will be...
28
by: Jess | last post by:
Hello, It is said that if I implement a "swap" member function, then it should never throw any exception. However, if I implement "swap" non- member function, then the restriction doesn't...
6
by: =?Utf-8?B?QnJpYW4gTmljaG9sc29u?= | last post by:
How do I know which exceptions a function throws? In my application, I make a call to DirectoryInfo.GetDirectories("\\NetworkPath\Path"). I check for System.IO.DirectoryNotFoundException and...
12
by: raj s | last post by:
What is the advantage and disadvantage of using function declaration with exceptions specified. like foo()throws(char&)
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.